Skip to content

Commit

Permalink
libcommon: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Sep 6, 2012
1 parent a3a4cba commit 8eae9a6
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 135 deletions.
73 changes: 52 additions & 21 deletions doomsday/plugins/common/include/g_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,49 @@ enum {

extern boolean singledemo;

void G_Register(void);
void G_Register(void);

void G_EndGame(void);
boolean G_QuitInProgress(void);
gamestate_t G_GameState(void);
void G_ChangeGameState(gamestate_t state);

gameaction_t G_GameAction(void);
void G_SetGameAction(gameaction_t action);

const char* P_GetGameModeName(void);

/**
* Begin the titlescreen animation sequence.
*/
void G_StartTitle(void);
void G_StartTitle(void);

/**
* Begin the helpscreen animation sequence.
*/
void G_StartHelp(void);

const char* P_GetGameModeName(void);
void G_StartHelp(void);

gamestate_t G_GameState(void);
void G_ChangeGameState(gamestate_t state);
void G_EndGame(void);

gameaction_t G_GameAction(void);
void G_SetGameAction(gameaction_t action);
boolean G_QuitInProgress(void);

/**
* @param map Logical map number (i.e., not a warp/translated number).
* @param mapEntryPoint Logical map entry point number.
*/
void G_NewGame(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
void G_DeferredNewGame(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
void G_NewGame(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
void G_DeferredNewGame(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);

#if __JHEXEN__
/**
* Same as @ref G_DeferredNewGame() except a GA_SETMAP action is queued
* instead of GA_NEWGAME.
*/
void G_DeferredSetMap(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
void G_DeferredSetMap(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
#endif

/**
* Signal that play on the current map may now begin.
*/
void G_BeginMap(void);
void G_BeginMap(void);

/**
* Leave the current map and start intermission routine.
Expand All @@ -96,14 +97,44 @@ void G_BeginMap(void);
* @param mapEntryPoint Logical map entry point on the new map.
* @param secretExit @c true if the exit taken was marked as 'secret'.
*/
void G_LeaveMap(uint newMap, uint mapEntryPoint, boolean secretExit);
void G_LeaveMap(uint newMap, uint mapEntryPoint, boolean secretExit);

/**
* Compose a Uri for the identified @a episode and @a map combination.
*
* @param episode Logical episode number.
* @param map Logical map number.
*
* @return Resultant Uri. Must be destroyed with Uri_Delete() when no longer needed.
*/
Uri* G_ComposeMapUri(uint episode, uint map);

/**
* Determine if the specified @a episode and @a map value pair are valid and if not,
* adjust their are values within the ranges defined by the current game type and mode.
*
* @param episode Logical episode number to be validated.
* @param map Logical map number to be validated.
*
* @return @c true= The original @a episode and @a map value pair were already valid.
*/
boolean G_ValidateMap(uint* episode, uint* map);

/**
* Return the next map according to the default map progression.
*
* @param episode Current episode.
* @param map Current map.
* @param secretExit
*
* @return The next map.
*/
uint G_GetNextMap(uint episode, uint map, boolean secretExit);

/// @return Generated name. Must be released with Str_Delete()
AutoStr* G_GenerateSaveGameName(void);
/// @return Logical map number.
uint G_GetMapNumber(uint episode, uint map);

int P_CameraXYMovement(mobj_t* mo);
int P_CameraZMovement(mobj_t* mo);
void P_Thrust3D(struct player_s* player, angle_t angle, float lookdir, coord_t forwardMove, coord_t sideMove);
AutoStr* G_GenerateSaveGameName(void);

D_CMD( CCmdMakeLocal );
D_CMD( CCmdSetCamera );
Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/common/include/p_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,8 @@ int P_PlayerGiveArmorBonus(player_t* plr, int points);
int P_PlayerGiveArmorBonus(player_t* plr, armortype_t type, int points);
#endif

int P_CameraXYMovement(mobj_t* mo);
int P_CameraZMovement(mobj_t* mo);
void P_Thrust3D(struct player_s* player, angle_t angle, float lookdir, coord_t forwardMove, coord_t sideMove);

#endif /* LIBCOMMON_PLAYER_H */
24 changes: 1 addition & 23 deletions doomsday/plugins/common/src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ void G_DoSaveGame(void);
void G_DoScreenShot(void);
void G_DoQuitGame(void);

boolean G_ValidateMap(uint* episode, uint* map);

void G_StopDemo(void);

/**
Expand Down Expand Up @@ -3175,9 +3173,6 @@ const char* P_GetGameModeName(void)
return sp;
}

/**
* Return the index of this map.
*/
uint G_GetMapNumber(uint episode, uint map)
{
#if __JHEXEN__
Expand All @@ -3199,12 +3194,6 @@ uint G_GetMapNumber(uint episode, uint map)
Uri* G_ComposeMapUri(uint episode, uint map)
{
lumpname_t mapId;
G_MapId(episode, map, mapId);
return Uri_NewWithPath2(mapId, RC_NULL);
}

void G_MapId(uint episode, uint map, lumpname_t mapId)
{
#if __JDOOM64__
dd_snprintf(mapId, LUMPNAME_T_MAXLEN, "MAP%02u", map+1);
#elif __JDOOM__
Expand All @@ -3217,12 +3206,9 @@ void G_MapId(uint episode, uint map, lumpname_t mapId)
#else
dd_snprintf(mapId, LUMPNAME_T_MAXLEN, "MAP%02u", map+1);
#endif
return Uri_NewWithPath2(mapId, RC_NULL);
}

/**
* Returns true if the specified (episode, map) pair can be used.
* Otherwise the values are adjusted so they are valid.
*/
boolean G_ValidateMap(uint* episode, uint* map)
{
boolean ok = true;
Expand Down Expand Up @@ -3347,14 +3333,6 @@ boolean G_ValidateMap(uint* episode, uint* map)
return ok;
}

/**
* Return the next map according to the default map progression.
*
* @param episode Current episode.
* @param map Current map.
* @param secretExit
* @return The next map.
*/
uint G_GetNextMap(uint episode, uint map, boolean secretExit)
{
#if __JHEXEN__
Expand Down
17 changes: 3 additions & 14 deletions doomsday/plugins/common/src/p_mapsetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,11 @@
#include <ctype.h> // has isspace
#include <string.h>

#if __JDOOM__
# include "jdoom.h"
#elif __JDOOM64__
# include "jdoom64.h"
#elif __JHERETIC__
# include "jheretic.h"
#elif __JHEXEN__
# include "jhexen.h"
#endif
#include "common.h"

#include "am_map.h"
#include "dmu_lib.h"
#include "g_common.h"
#include "r_common.h"
#include "p_actor.h"
#include "p_mapsetup.h"
Expand Down Expand Up @@ -709,12 +702,8 @@ void P_SetupMap(Uri* mapUri, uint episode, uint map)
#if __JHEXEN__
PO_InitForMap();

{ lumpname_t mapId;
G_MapId(episode, map, mapId);
Con_Message("Load ACS scripts\n");
// @todo Should be interpreted by the map converter.
P_LoadACScripts(W_GetLumpNumForName(mapId) + 11 /*ML_BEHAVIOR*/); // ACS object code
}
P_LoadACScripts(W_GetLumpNumForName(Str_Text(Uri_Path(mapUri))) + 11 /*ML_BEHAVIOR*/); // ACS object code
#endif

HU_UpdatePsprites();
Expand Down
19 changes: 0 additions & 19 deletions doomsday/plugins/jdoom/include/g_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ void G_CommonShutdown(void);
void R_InitRefresh(void);

void G_PrintMapList(void);
boolean G_ValidateMap(uint* episode, uint* map);
uint G_GetMapNumber(uint episode, uint map);

void G_DeferredPlayDemo(char* demo);

Expand Down Expand Up @@ -115,23 +113,6 @@ int G_DebriefingEnabled(uint episode, uint map, ddfinale_t* fin);
void G_DoReborn(int playernum);
void G_PlayerReborn(int player);

uint G_GetNextMap(uint episode, uint map, boolean secretExit);

/**
* Compose a Uri for the identified @a episode and @a map combination.
*
* @param episode Logical episode number.
* @param map Logical map number.
* @return Resultant Uri. Caller should destroy with Uri_Delete.
*/
Uri* G_ComposeMapUri(uint episode, uint map);

/**
* Compose the name of the map identifier.
* \note Deprecated. Prefer to use G_ComposeMapUri
*/
void G_MapId(uint episode, uint map, lumpname_t mapId);

void G_WorldDone(void);

void G_Ticker(timespan_t ticLength);
Expand Down
19 changes: 0 additions & 19 deletions doomsday/plugins/jdoom64/include/g_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ void R_InitRefresh(void);
void G_DeathMatchSpawnPlayer(int playernum);

void G_PrintMapList(void);
boolean G_ValidateMap(uint* episode, uint* map);
uint G_GetMapNumber(uint episode, uint map);

void G_DeferredPlayDemo(char* demo);

Expand Down Expand Up @@ -117,23 +115,6 @@ int G_DebriefingEnabled(uint episode, uint map, ddfinale_t* fin);
void G_DoReborn(int playernum);
void G_PlayerReborn(int player);

uint G_GetNextMap(uint episode, uint map, boolean secretExit);

/**
* Compose a Uri for the identified @a episode and @a map combination.
*
* @param episode Logical episode number.
* @param map Logical map number.
* @return Resultant Uri. Caller should destroy with Uri_Delete.
*/
Uri* G_ComposeMapUri(uint episode, uint map);

/**
* Compose the name of the map identifier.
* \note Deprecated. Prefer to use G_ComposeMapUri
*/
void G_MapId(uint episode, uint map, lumpname_t mapId);

void G_WorldDone(void);

void G_Ticker(timespan_t ticLength);
Expand Down
19 changes: 0 additions & 19 deletions doomsday/plugins/jheretic/include/g_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ void R_InitRefresh(void);
void G_DeathMatchSpawnPlayer(int playernum);

void G_PrintMapList(void);
boolean G_ValidateMap(uint* episode, uint* map);
uint G_GetMapNumber(uint episode, uint map);

void G_DeferredPlayDemo(char* demo);

Expand Down Expand Up @@ -116,23 +114,6 @@ int G_DebriefingEnabled(uint episode, uint map, ddfinale_t* fin);
void G_DoReborn(int playernum);
void G_PlayerReborn(int player);

uint G_GetNextMap(uint episode, uint map, boolean secretExit);

/**
* Compose a Uri for the identified @a episode and @a map combination.
*
* @param episode Logical episode number.
* @param map Logical map number.
* @return Resultant Uri. Caller should destroy with Uri_Delete.
*/
Uri* G_ComposeMapUri(uint episode, uint map);

/**
* Compose the name of the map identifier.
* \note Deprecated. Prefer to use G_ComposeMapUri
*/
void G_MapId(uint episode, uint map, lumpname_t mapId);

void G_WorldDone(void);

void G_Ticker(timespan_t ticLength);
Expand Down
18 changes: 0 additions & 18 deletions doomsday/plugins/jhexen/include/g_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,10 @@ void R_GetTranslation(int plrClass, int plrColor, int* tclass, int* t
void Mobj_UpdateTranslationClassAndMap(mobj_t* mo);

void G_PrintMapList(void);
boolean G_ValidateMap(uint* episode, uint* map);
uint G_GetNextMap(uint episode, uint map, boolean secretExit);

int G_BriefingEnabled(uint episode, uint map, ddfinale_t* fin);
int G_DebriefingEnabled(uint episode, uint map, ddfinale_t* fin);

/**
* Compose a Uri for the identified @a episode and @a map combination.
*
* @param episode Logical episode number.
* @param map Logical map number.
* @return Resultant Uri. Caller should destroy with Uri_Delete.
*/
Uri* G_ComposeMapUri(uint episode, uint map);

/**
* Compose the name of the map identifier.
* \note Deprecated. Prefer to use G_ComposeMapUri
*/
void G_MapId(uint episode, uint map, lumpname_t mapId);

void G_QuitGame(void);

/// @return @c true = loading is presently possible.
Expand Down Expand Up @@ -127,7 +110,6 @@ void* G_GetVariable(int id);

void G_PlayerReborn(int player);
void G_DeathMatchSpawnPlayer(int playernum);
uint G_GetMapNumber(uint episode, uint map);
void G_DeferredPlayDemo(char* demo);
void G_DoPlayDemo(void);

Expand Down
7 changes: 5 additions & 2 deletions doomsday/plugins/jhexen/src/p_acs.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ void P_LoadACScripts(int lump)
acsinfo_t* info;
int i;

VERBOSE( Con_Message("Loading ACS bytecode lump %s:%s (#%i)...\n",
F_PrettyPath(W_LumpSourceFile(lump)), W_LumpName(lump), lump) )
ACScriptCount = 0;

if(lumpLength >= sizeof(acsheader_t))
Expand All @@ -271,8 +273,9 @@ void P_LoadACScripts(int lump)
}

if(ACScriptCount == 0 || IS_CLIENT)
{ // Empty/Invalid lump.
Con_Message("Warning:P_LoadACSScripts: lumpnum %i does not appear to be valid ACS bytecode, ignoring.\n", lump);
{
// Empty/Invalid lump.
Con_Message("Warning: P_LoadACSScripts: lumpnum %i does not appear to be valid ACS bytecode, ignoring.\n", lump);
return;
}

Expand Down

0 comments on commit 8eae9a6

Please sign in to comment.