aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/pet_messages.go (1138B)


      1 package main
      2 
      3 // Dismissal was authorized by the owner's zone. Recheck the pet identity in its
      4 // own zone and commit retirement before notifying the owner's current zone.
      5 type petDismissal struct {
      6 	owner, pet uint32
      7 }
      8 
      9 func (command petDismissal) execute(state *server) error {
     10 	pet := state.characters[command.pet]
     11 	if pet.pet == nil || pet.pet.owner != command.owner {
     12 		return nil
     13 	}
     14 	updates := make(map[*worldClient][][]byte)
     15 	if err := state.retirePet(pet, updates); err != nil {
     16 		return err
     17 	}
     18 	state.sendCombatUpdates(updates)
     19 	return nil
     20 }
     21 
     22 type petRetired struct {
     23 	owner, pet uint32
     24 }
     25 
     26 func (command petRetired) execute(state *server) error {
     27 	owner := state.characters[command.owner]
     28 	if !owner.pets[command.pet] {
     29 		return nil
     30 	}
     31 	delete(owner.pets, command.pet)
     32 	updates := make(map[*worldClient][][]byte)
     33 	for id, client := range state.clients {
     34 		if client.ready && client.sees(owner) && state.characters[id].playfield == owner.playfield {
     35 			updates[client] = append(updates[client], petIdentityPacket(0x58742a0f, owner.id, command.pet), petCounterPacket(owner))
     36 		}
     37 	}
     38 	state.sendCombatUpdates(updates)
     39 	return nil
     40 }