Amulets & Armor  v1.02
Open Source Game
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Functions | Variables
SERVER

Server/World Code. More...

Macros

#define MAX_PLAYERS   4
 
#define SERVER_PLAYER_NONE   0xFFFF
 
#define SERVER_TIME_BETWEEN_OBJECT_UPDATES   7
 
#define SYNC_TIMING   (70*1)
 

Functions

E_Boolean IServerCheckSectorSoundsForObject (T_3dObject *p_obj, T_word32 data)
 
T_3dObjectServerCreateFakeObjectGlobal (T_word16 objType, T_sword16 x, T_sword16 y, T_sword16 z)
 
T_3dObjectServerCreateObjectGlobal (T_word16 objType, T_sword16 x, T_sword16 y, T_sword16 z)
 
T_void ServerDamageAtWithType (T_sword16 x, T_sword16 y, T_sword16 z, T_word16 radius, T_word16 damage, T_word16 ownerID, T_byte8 type)
 
T_void ServerDestroyDestroyObjects (T_void)
 
T_void ServerFinish (T_void)
 
T_sword16 ServerGetNextPlayer (T_player lastPlayer)
 
T_3dObjectServerGetPlayerObject (T_word16 playerId)
 
T_word32 ServerGetServerID (T_void)
 
T_void ServerGotoPlace (T_word32 placeNumber, T_word16 startLocation)
 
T_void ServerInit (T_void)
 
T_void ServerPlayerLeft (T_player player)
 
T_void ServerReceiveChangePasswordPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveCheckPasswordPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveCreateCharacterPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveDeleteCharacterPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveGotoPlacePacket (T_packetEitherShortOrLong *p_gotoPacket)
 
T_void ServerReceiveGotoSucceededPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveLoadCharacterPacket (T_packetEitherShortOrLong *p_packet)
 
T_3dObjectServerReceiveProjectileAddPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveRequestCharacterListPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveRequestEnterPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerReceiveSyncPacket (T_packetEitherShortOrLong *p_packet)
 
T_void ServerSetServerID (T_word32 newID)
 
T_void ServerShootBasicProjectile (T_word16 objectType, T_sword32 x, T_sword32 y, T_sword32 z, T_sword32 targetX, T_sword32 targetY, T_sword32 targetZ, T_word16 initialSpeed)
 
T_3dObjectServerShootProjectile (T_3dObject *p_objSource, T_word16 angle, T_word16 typeObj, T_word16 initSpeed, T_3dObject *p_target)
 
T_void ServerUpdate (T_void)
 

Variables

E_Boolean G_serverActive = FALSE
 
T_sword32 G_sourceX
 
T_sword32 G_sourceY
 
T_sword32 G_sourceZ
 

Detailed Description

Server/World Code.

The Server code responds to requests from the players to perform actions. This top level code handles those requests usually passing off the requests to others.

See Also
http://www.amuletsandarmor.com/AALicense.txt

Macro Definition Documentation

#define MAX_PLAYERS   4
#define SERVER_PLAYER_NONE   0xFFFF
#define SERVER_TIME_BETWEEN_OBJECT_UPDATES   7
#define SYNC_TIMING   (70*1)

Function Documentation

E_Boolean IServerCheckSectorSoundsForObject ( T_3dObject p_obj,
T_word32  data 
)

IServerCheckSectorSoundsForObject sees if an object is on a group of sectors with the same "entry sound." If it is, the sound is produced given that the object has not recently created the sound. This is used for making splashing sounds.

Parameters
p_obj– Player object to identify
data– This is currently always zero
T_3dObject* ServerCreateFakeObjectGlobal ( T_word16  objType,
T_sword16  x,
T_sword16  y,
T_sword16  z 
)
T_3dObject* ServerCreateObjectGlobal ( T_word16  objType,
T_sword16  x,
T_sword16  y,
T_sword16  z 
)
T_void ServerDamageAtWithType ( T_sword16  x,
T_sword16  y,
T_sword16  z,
T_word16  radius,
T_word16  damage,
T_word16  ownerID,
T_byte8  type 
)

ServerDamageAtWithType does damage to a given location. If the given radius is nonzero, does damage to anything within the radius.

Parameters
x– X Exact location
y– Y Exact location
z– Z Exact location
radius– Sphereical radius
damage– Amount of damage to do
ownerID– Owner of damage being done
type– Type of damage to do
T_void ServerDestroyDestroyObjects ( T_void  )

ServerDestroyDestroyObjects goes through the list of objects and checks if there any objects that are requesting self-destruction. If there is, an appropriate packet is sent and the object is eliminated.

T_void ServerFinish ( T_void  )

ServerFinish cleans up the server.

T_sword16 ServerGetNextPlayer ( T_player  lastPlayer)

ServerGetNextPlayer is used to traverse through all the players in the game. Use -1 to get the first player and then continue. When a -1 is returned, you know that you are at the end of the list.

Parameters
lastPlayer– Player to start from or -1 for first
Returns
next player.
T_3dObject* ServerGetPlayerObject ( T_word16  playerId)

ServerGetPlayerObject finds a player and returns its object. If none is found, NULL is returned.

Parameters
playerId– Player's Id
Returns
Player's object, or NULL if not found

Just always return the object pointer.

T_word32 ServerGetServerID ( T_void  )

ServerGetServerID returns the server id of this server.

Returns
Server id
T_void ServerGotoPlace ( T_word32  placeNumber,
T_word16  startLocation 
)

ServerGotoPlace is called to force all logged-in clients to go to a map or form. It has the same effect as receiving a goto-place packet from a client. New behavior (AMT, 9/13/95) Place numbers fit into the following groups, specified by their high 2 bytes. 0000 - 00FF Levels. This allows for an absurd number of levels. Whenever a master receives one, a new slave server is forked off and begins an adventure. Whenever a slave receives one, it just advances to that level. 0100 - 01FF Forms. Mail rooms, inns, etc. Whenever one of these is received by a slave, it terminates and returns control to the master. Masters handle normally. 0200 Currently-running adventures. I.e. currently active slaves which the client wishes to join. Slave receives and ignores. Master receives and tells the appropriate slave.

Parameters
placeNumber– the place to go to.
startLocation– Numerical start location.

Normal mode.

Is this a next-map instruction?

Create a GOTO_PLACE packet.

Just send an identical packet to each client.

T_void ServerInit ( T_void  )

ServerInit starts up the server and gets everything in order before any other actions can occur.

NOTE: Must be called before all other ServerXXX commands.

Register my callback routines.

T_void ServerPlayerLeft ( T_player  player)
T_void ServerReceiveChangePasswordPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveChangePasswordPacket is called when the client wishes to change her password on the system.

NOTE: This code is intended for the Self Server mode ONLY.

Parameters
p_packet– change password packet
T_void ServerReceiveCheckPasswordPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveCheckPasswordPacket is called when the client wishes to check the password on a character of a given slot.

NOTE: This code is intended for the Self Server mode ONLY.

Parameters
p_packet– check passwordpacket
T_void ServerReceiveCreateCharacterPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveCreateCharacterPacket is called when the client wishes to create a new character in the given slot. At the same time the character will be uploaded.

NOTE: This code is intended for the Self Server mode ONLY.

Parameters
p_packet– craete char packet
T_void ServerReceiveDeleteCharacterPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveDeleteCharacterPacket is called when the client wishes to delete a new character in the given slot. At the same time the character will be uploaded.

NOTE: This code is intended for the Self Server mode ONLY.

Parameters
p_packet– delete char packet
T_void ServerReceiveGotoPlacePacket ( T_packetEitherShortOrLong p_gotoPacket)

ServerReceiveGotoPlacePacket is called when a client reqests a map or form change. It basically loads in the new map and sends a copy of the request to all the other clients.

Parameters
p_gotoPacket– the goto place packet.
T_void ServerReceiveGotoSucceededPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveGotoSucceededPacket is called when a client has success- fully complied with a GotoPlace packet. This lets me know when every- body is ready.

Parameters
p_packet– the goto success packet.

First! Ensure that this packet corresponds to the place change in

progress.

Yes! Make the server update loop active again.

Yes.

Send everyone a place start packet and positional

T_void ServerReceiveLoadCharacterPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveLoadCharacterPacket is called when the client wishes to either see if a character needs to be downloaded or if the checksums are correct, noted.

NOTE: This code is intended for the Self Server mode ONLY.

Parameters
p_packet– load char packet
T_3dObject* ServerReceiveProjectileAddPacket ( T_packetEitherShortOrLong p_packet)

A PROJECTILE_CREATE packet is used as an alternative to an OBJECT_CREATE when the new object is thrown, fired, or otherwise projected from a known origin object. This allows the packet to be SHORT rather than LONG, since a good deal of positional information is implicit and doesn't need to be sent. This routine handles these packets.

Parameters
p_packet– objectAdd packet
Returns
Created object

Get a pointer to the add packet data.

Create a new object in my world.

Set its type according to the packet instructions.

Set up its movement parameters.

Did everything go alright?

Yes. Now that it's ready, add it to the world.

That concludes my local object creation.

To tell all the clients to create it too, I just send them all

the same packet, plus my server ID value.

T_void ServerReceiveRequestCharacterListPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveRequestCharacterListPacket is called when the client wishes to know what characters are available for this account.

NOTE: This code is intended for the Self Server mode ONLY. It just makes a call to StatsGetSavedCharacterList and starts a memory transfer.

Parameters
p_packet– request enter packet
T_void ServerReceiveRequestEnterPacket ( T_packetEitherShortOrLong p_packet)

ServerReceiveRequestEnterPacket is called when a client is wanting to receive info about if he can enter.

Parameters
p_packet– request enter packet
T_void ServerReceiveSyncPacket ( T_packetEitherShortOrLong p_packet)
T_void ServerSetServerID ( T_word32  newID)

ServerSetServerID sets the server id of this server.

Parameters
newID– Server id
T_void ServerShootBasicProjectile ( T_word16  objectType,
T_sword32  x,
T_sword32  y,
T_sword32  z,
T_sword32  targetX,
T_sword32  targetY,
T_sword32  targetZ,
T_word16  initialSpeed 
)

ServerShootBasicProjectile is called to create an object at a specific location and with specific velocities.

Parameters
objectType– Type of object projectile
x– X Position to start projectile
y– Y Position to start projectile
z– Z Position to start projectile
targetX– X Target position for missile
targetY– Y Target position for missile
targetZ– Z Target position for missile
initialSpeed– How fast to shoot the missile
T_3dObject* ServerShootProjectile ( T_3dObject p_objSource,
T_word16  angle,
T_word16  typeObj,
T_word16  initSpeed,
T_3dObject p_target 
)

ServerShootProjectile is a routine that will create a projectile by setting up a projectile packet and then sending it to itself. This will cause the packet to be sent to all the clients and the object to be created (with an appropriate server id).

Parameters
p_objSource– Object doing the shooting
angle– Angle to shoot the projectile
typeObj– Object type (fireball?)
initSpeed– How fast. Note this is a small value
p_target– Target to shoot at (or NULL for none)
Returns
Created projectile, NULL for none

Target.

T_void ServerUpdate ( T_void  )

ServerUpdate goes through all the code execution necessary to update the server actions in one time slice.

Keep track of the deltas.

Apply all velocities to the objects.

Then, send out all necessary movement packets.

Variable Documentation

E_Boolean G_serverActive = FALSE
T_sword32 G_sourceX
T_sword32 G_sourceY
T_sword32 G_sourceZ