Skip to content

Commit

Permalink
World|Client: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 10, 2014
1 parent 5ea7600 commit 63b6570
Show file tree
Hide file tree
Showing 16 changed files with 419 additions and 555 deletions.
52 changes: 25 additions & 27 deletions doomsday/client/include/client/cl_def.h
@@ -1,4 +1,4 @@
/** @file
/** @file cl_def.h Client definitions.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2007-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -17,43 +17,41 @@
* http://www.gnu.org/licenses</small>
*/

/**
* cl_def.h: Client Definitions
*/

#ifndef __DOOMSDAY_CLIENT_H__
#define __DOOMSDAY_CLIENT_H__
#ifndef DENG_CLIENT_H
#define DENG_CLIENT_H

#include "world/p_object.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SHORTP(x) (*(short*) (x))
#define USHORTP(x) (*(unsigned short*) (x))

extern ident_t clientID;
extern int serverTime;
extern boolean handshakeReceived;
extern int gameReady;
extern boolean netLoggedIn;
extern int clientPaused;
DENG_EXTERN_C ident_t clientID;
DENG_EXTERN_C int serverTime;
DENG_EXTERN_C boolean handshakeReceived;
DENG_EXTERN_C int gameReady;
DENG_EXTERN_C boolean netLoggedIn;
DENG_EXTERN_C int clientPaused;

void Cl_InitID(void);
void Cl_CleanUp(void);
void Cl_GetPackets(void);
void Cl_Ticker(timespan_t ticLength);
int Cl_GameReady(void);
void Cl_InitID();

void Cl_CleanUp();

/**
* Client's packet handler. Handles all the events the server sends.
*/
void Cl_GetPackets();

/**
* Client-side game ticker.
*/
void Cl_Ticker(timespan_t ticLength);

int Cl_GameReady();

/**
* Sends a hello packet.
* PCL_HELLO2 includes the Game ID (16 chars).
*/
void Cl_SendHello();

#ifdef __cplusplus
} // extern "C"
#endif

#endif
#endif // DENG_CLIENT_H
29 changes: 11 additions & 18 deletions doomsday/client/include/client/cl_frame.h
@@ -1,4 +1,4 @@
/** @file
/** @file cl_frame.h Client frame reception.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2007-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -17,24 +17,17 @@
* http://www.gnu.org/licenses</small>
*/

/**
* cl_frame.h: Frame Reception
*/

#ifndef __DOOMSDAY_CLIENT_FRAME_H__
#define __DOOMSDAY_CLIENT_FRAME_H__
#ifndef DENG_CLIENT_FRAME_H
#define DENG_CLIENT_FRAME_H

#ifdef __cplusplus
extern "C" {
#endif
void Cl_InitFrame();
void Cl_ResetFrame();

void Cl_InitFrame(void);
void Cl_ResetFrame(void);
void Cl_Frame2Received(int packetType);
float Cl_FrameGameTime(void);
/**
* Read a PSV_FRAME2/PSV_FIRST_FRAME2 packet.
*/
void Cl_Frame2Received(int packetType);

#ifdef __cplusplus
} // extern "C"
#endif
float Cl_FrameGameTime();

#endif
#endif // DENG_CLIENT_FRAME_H
23 changes: 6 additions & 17 deletions doomsday/client/include/client/cl_infine.h
@@ -1,4 +1,4 @@
/** @file
/** @file cl_infine.h Clientside InFine.
*
* @authors Copyright © 2010 Daniel Swanson <danij@dengine.net>
*
Expand All @@ -16,33 +16,22 @@
* http://www.gnu.org/licenses</small>
*/

/**
* Client-side InFine.
*/

#ifndef DENG_CLIENT_INFINE
#define DENG_CLIENT_INFINE

#include "api_infine.h"
#include <de/reader.h>

#ifdef __cplusplus
extern "C" {
#endif

finaleid_t Cl_CurrentFinale(void);
finaleid_t Cl_CurrentFinale();

/**
* This is where clients start their InFine sequences.
*/
void Cl_Finale(Reader* msg);
void Cl_Finale(Reader *msg);

/**
* Client sends a request to skip the finale.
*/
void Cl_RequestFinaleSkip(void);

#ifdef __cplusplus
} // extern "C"
#endif
void Cl_RequestFinaleSkip();

#endif /* DENG_CLIENT_INFINE */
#endif // DENG_CLIENT_INFINE
38 changes: 14 additions & 24 deletions doomsday/client/include/client/cl_mobj.h
@@ -1,8 +1,8 @@
/** @file cl_mobj.h Clientside map objects.
/** @file cl_mobj.h Clientside map objects.
* @ingroup client
*
* @author Copyright &copy; 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2006-2013 Daniel Swanson <danij@dengine.net>
* @author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -18,8 +18,8 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef __DOOMSDAY_CLIENT_MOBJ_H__
#define __DOOMSDAY_CLIENT_MOBJ_H__
#ifndef DENG_CLIENT_WORLD_MOBJ_H
#define DENG_CLIENT_WORLD_MOBJ_H

#include "world/p_object.h"

Expand Down Expand Up @@ -57,19 +57,15 @@
* gameside mobjs. The last 4 bytes must be CLM_MAGIC.
*/
typedef struct clmoinfo_s {
uint startMagic; // The client mobj magic number (CLM_MAGIC1).
uint startMagic; // The client mobj magic number (CLM_MAGIC1).
struct clmoinfo_s *next, *prev;
int flags;
uint time; // Time of last update.
int sound; // Queued sound ID.
float volume; // Volume for queued sound.
uint endMagic; // The client mobj magic number (CLM_MAGIC2).
int flags;
uint time; // Time of last update.
int sound; // Queued sound ID.
float volume; // Volume for queued sound.
uint endMagic; // The client mobj magic number (CLM_MAGIC2).
} clmoinfo_t;

#ifdef __cplusplus
extern "C" {
#endif

/**
* Make the real player mobj identical with the client mobj.
* The client mobj is always unlinked. Only the *real* mobj is visible.
Expand Down Expand Up @@ -143,16 +139,14 @@ void ClMobj_SetState(mobj_t *mo, int stnum); // needed?
*
* For client mobjs that belong to players, updates the real player mobj
* accordingly.
*
* @param skip If @c true, all read data is ignored.
*/
void ClMobj_ReadDelta2(boolean skip);
void ClMobj_ReadDelta();

/**
* Null mobjs deltas have their own type in a PSV_FRAME2 packet.
* Here we remove the mobj in question.
*/
void ClMobj_ReadNullDelta2(boolean skip);
void ClMobj_ReadNullDelta();

/**
* Determines whether a mobj is a client mobj.
Expand All @@ -163,8 +157,4 @@ void ClMobj_ReadNullDelta2(boolean skip);
*/
boolean Cl_IsClientMobj(mobj_t *mo); // public

#ifdef __cplusplus
} // extern "C"
#endif

#endif
#endif // DENG_CLIENT_WORLD_MOBJ_H
86 changes: 45 additions & 41 deletions doomsday/client/include/client/cl_player.h
@@ -1,4 +1,4 @@
/** @file cl_player.h
/** @file cl_player.h Clientside player management.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2007-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -17,72 +17,76 @@
* http://www.gnu.org/licenses</small>
*/

/**
* Clientside Player Management
*/

#ifndef DENG_CLIENT_PLAYER_H
#define DENG_CLIENT_PLAYER_H

#include "cl_mobj.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Information about a client player.
*/
typedef struct clplayerstate_s {
thid_t clMobjId;
float forwardMove;
float sideMove;
int angle;
angle_t turnDelta;
int friction;
int pendingFixes;
thid_t pendingFixTargetClMobjId;
angle_t pendingAngleFix;
float pendingLookDirFix;
coord_t pendingOriginFix[3];
coord_t pendingMomFix[3];
thid_t clMobjId;
float forwardMove;
float sideMove;
int angle;
angle_t turnDelta;
int friction;
int pendingFixes;
thid_t pendingFixTargetClMobjId;
angle_t pendingAngleFix;
float pendingLookDirFix;
coord_t pendingOriginFix[3];
coord_t pendingMomFix[3];
} clplayerstate_t;

extern float pspMoveSpeed;
extern float cplrThrustMul;
DENG_EXTERN_C float pspMoveSpeed;
DENG_EXTERN_C float cplrThrustMul;

void Cl_InitPlayers(void);
/**
* Clears the player state table.
*/
void Cl_InitPlayers();

/**
* Used in DEMOS. (Not in regular netgames.)
* Applies the given dx and dy to the local player's coordinates.
*
* @param dx Viewpoint X delta.
* @param dy Viewpoint Y delta.
* @param z Viewpoint absolute Z coordinate.
* @param onground If @c true the mobj's Z will be set to floorz, and
* the player's viewheight is set so that the viewpoint
* height is param 'z'.
* If @c false the mobj's Z will be param 'z' and
* viewheight is zero.
* @param dx Viewpoint X delta.
* @param dy Viewpoint Y delta.
* @param z Viewpoint absolute Z coordinate.
* @param onground If @c true the mobj's Z will be set to floorz, and the player's
* viewheight is set so that the viewpoint height is param 'z'.
* If @c false the mobj's Z will be param 'z' and viewheight is zero.
*/
void ClPlayer_MoveLocal(coord_t dx, coord_t dy, coord_t z, boolean onground);
void ClPlayer_MoveLocal(coord_t dx, coord_t dy, coord_t z, bool onground);

/**
* Move the (hidden, unlinked) client player mobj to the same coordinates
* where the real mobj of the player is.
*/
void ClPlayer_UpdateOrigin(int plrnum);

void ClPlayer_HandleFix(void);
void ClPlayer_ApplyPendingFixes(int plrNum);
void ClPlayer_ReadDelta2(boolean skip);
void ClPlayer_HandleFix();

void ClPlayer_ApplyPendingFixes(int plrNum);

/**
* Reads a single PSV_FRAME2 player delta from the message buffer and
* applies it to the player in question.
*/
void ClPlayer_ReadDelta();

clplayerstate_t *ClPlayer_State(int plrNum);
mobj_t *ClPlayer_LocalGameMobj(int plrNum);
boolean ClPlayer_IsFreeToMove(int plrnum);

#ifdef __cplusplus
} // extern "C"
#endif
/**
* Returns the gameside local mobj of a player.
*/
mobj_t *ClPlayer_LocalGameMobj(int plrNum);

/**
* Returns @c true iff the player is free to move according to floorz and ceilingz.
*/
bool ClPlayer_IsFreeToMove(int plrnum);

#endif // DENG_CLIENT_PLAYER_H

0 comments on commit 63b6570

Please sign in to comment.