Skip to content

Commit

Permalink
Multiplayer: Server sends its materials to clients
Browse files Browse the repository at this point in the history
This will ensure that even though a different set of resources
has been loaded on the client, the materials will not be mixed up.

Uses MaterialArchive to pass the materials to the clients.

Removed obsolete code for client "lump translation", which was
originally intended to handle this issue but is now completely
outdated.
  • Loading branch information
skyjake committed Jan 12, 2012
1 parent 5159d98 commit 4c2d014
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 210 deletions.
3 changes: 2 additions & 1 deletion doomsday/engine/api/doomsday.def
@@ -1,6 +1,6 @@
; Doomsday Engine API (Routines exported from Doomsday.exe).
;
; Highest ordinal is currently: --> 750 <--
; Highest ordinal is currently: --> 751 <--
; Other free ordinals:
; none

Expand Down Expand Up @@ -900,3 +900,4 @@ EXPORTS
MaterialArchive_Write @748 NONAME
MaterialArchive_Find @749 NONAME
MaterialArchive_FindUniqueSerialId @750 NONAME
MaterialArchive_Count @751 NONAME
11 changes: 10 additions & 1 deletion doomsday/engine/api/materialarchive.h
Expand Up @@ -56,12 +56,21 @@ void MaterialArchive_Delete(MaterialArchive* arc);
*/
materialarchive_serialid_t MaterialArchive_FindUniqueSerialId(MaterialArchive* arc, struct material_s* mat);

/**
* @param group Set to zero. Only used with the version 0 of MaterialArchive (now obsolete).
*/
struct material_s* MaterialArchive_Find(MaterialArchive* arc, materialarchive_serialid_t serialId, int group);

/**
* Returns the number of materials in the archive.
*/
size_t MaterialArchive_Count(MaterialArchive* arc);

void MaterialArchive_Write(MaterialArchive* arc, Writer* writer);

/**
* @param forcedVersion Version to interpret as, not actual format version.
* @param forcedVersion Version to interpret as, not actual format version. Use -1 to use whatever
* version is encountered.
*/
void MaterialArchive_Read(MaterialArchive* arc, int forcedVersion, Reader* reader);

Expand Down
14 changes: 9 additions & 5 deletions doomsday/engine/portable/include/cl_world.h
Expand Up @@ -34,15 +34,19 @@ typedef enum {
MVT_CEILING
} clmovertype_t;

void Cl_InitTranslations(void);
void Cl_InitMovers(void);
void Cl_RemoveMovers(void);
lumpnum_t Cl_TranslateLump(lumpnum_t lumpNum);
void Cl_WorldInit(void);
void Cl_WorldReset(void);

/**
* Handles the PSV_MATERIAL_ARCHIVE packet sent by the server. The list of
* materials is stored until the client disconnects.
*/
void Cl_ReadServerMaterials(void);

void Cl_SetPolyMover(uint number, int move, int rotate);
void Cl_AddMover(uint sectornum, clmovertype_t type, float dest,
float speed);

int Cl_ReadLumpDelta(void);
void Cl_ReadSectorDelta2(int deltaType, boolean skip);
void Cl_ReadSideDelta2(int deltaType, boolean skip);
void Cl_ReadPolyDelta2(boolean skip);
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/net_main.h
Expand Up @@ -83,6 +83,7 @@ enum {
PSV_CONSOLE_TEXT = 11,
PCL_ACK_SHAKE = 12,
PSV_SYNC = 13,
PSV_MATERIAL_ARCHIVE = 14,
PCL_FINALE_REQUEST = 15,
PKT_LOGIN = 16,
PCL_ACK_SETS = 17,
Expand Down
6 changes: 6 additions & 0 deletions doomsday/engine/portable/include/sv_def.h
Expand Up @@ -49,6 +49,7 @@ extern char* netPassword; // Remote login password.

void Sv_Shutdown(void);
void Sv_StartNetGame(void);
void Sv_StopNetGame(void);
boolean Sv_PlayerArrives(unsigned int nodeID, char* name);
void Sv_PlayerLeaves(unsigned int nodeID);
void Sv_Handshake(int playernum, boolean newplayer);
Expand All @@ -70,4 +71,9 @@ int Sv_GetNumConnected(void);
boolean Sv_CheckBandwidth(int playerNumber);
boolean Sv_CanTrustClientPos(int plrNum);

/**
* Returns a unique id for material @a mat that can be passed on to clients.
*/
unsigned int Sv_IdForMaterial(material_t* mat);

#endif
8 changes: 6 additions & 2 deletions doomsday/engine/portable/src/cl_main.c
Expand Up @@ -117,7 +117,7 @@ void Cl_CleanUp(void)

Cl_DestroyClientMobjs();
Cl_InitPlayers();
Cl_RemoveMovers();
Cl_WorldReset();
GL_SetFilter(false);
}

Expand Down Expand Up @@ -207,7 +207,7 @@ void Cl_AnswerHandshake(void)

// Prepare the client-side data.
Cl_InitClientMobjs();
Cl_InitMovers();
Cl_WorldInit();

// Get ready for ticking.
DD_ResetTimer();
Expand Down Expand Up @@ -324,6 +324,10 @@ void Cl_GetPackets(void)
Cl_AnswerHandshake();
break;

case PSV_MATERIAL_ARCHIVE:
Cl_ReadServerMaterials();
break;

case PKT_PLAYER_INFO:
Cl_HandlePlayerInfo();
break;
Expand Down

0 comments on commit 4c2d014

Please sign in to comment.