Skip to content

Commit

Permalink
Refactor|libcommon: Command "setmap" is now an alias of "warp"
Browse files Browse the repository at this point in the history
The former is no longer necessary as management of game sessions and
game state is now more logical (in particular the saved ACS state in
Hexen is now managed as part of the map change process once the game
session begins).

When executed on server-side a warp command now respects the current
value of "server-game-skill" when (implicitly) starting a new game
session.

This needs testing (all games, multiplayer map cycle, etc...).
  • Loading branch information
danij-deng committed Aug 15, 2013
1 parent 74d36f0 commit cd20d82
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 175 deletions.
6 changes: 0 additions & 6 deletions doomsday/doc/libdoom/command/setmap.ame

This file was deleted.

6 changes: 0 additions & 6 deletions doomsday/doc/libheretic/command/setmap.ame

This file was deleted.

6 changes: 0 additions & 6 deletions doomsday/doc/libhexen/command/setmap.ame

This file was deleted.

8 changes: 0 additions & 8 deletions doomsday/plugins/common/include/g_common.h
Expand Up @@ -75,14 +75,6 @@ boolean G_QuitInProgress(void);
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);
#endif

/**
* Signal that play on the current map may now begin.
*/
Expand Down
73 changes: 0 additions & 73 deletions doomsday/plugins/common/src/d_net.c
Expand Up @@ -28,7 +28,6 @@
#include "doomsday.h"

D_CMD(SetColor);
D_CMD(SetMap);
#if __JHEXEN__
D_CMD(SetClass);
#endif
Expand Down Expand Up @@ -61,11 +60,6 @@ void D_NetConsoleRegistration(void)
C_VAR_INT2 ("server-game-cheat", &netSvAllowCheats, 0, 0, 1, notifyAllowCheatsChange);

C_CMD ("setcolor", "i", SetColor);
#if __JDOOM__ || __JHERETIC__ || __JDOOM64__
C_CMD ("setmap", "ii", SetMap);
#else
C_CMD ("setmap", "i", SetMap);
#endif
#if __JHEXEN__
C_CMD_FLAGS ("setclass", "i", SetClass, CMDF_NO_DEDICATED);
#endif
Expand Down Expand Up @@ -774,73 +768,6 @@ D_CMD(SetClass)
}
#endif

/**
* Console command to change the current map.
*/
D_CMD(SetMap)
{
uint ep, map;

// Only the server can change the map.
if(!IS_SERVER)
return false;

#if __JDOOM__ || __JHERETIC__
if(argc != 3)
{
Con_Printf("Usage: %s (episode) (map)\n", argv[0]);
return true;
}
#else
if(argc != 2)
{
Con_Printf("Usage: %s (map)\n", argv[0]);
return true;
}
#endif

// Parse arguments.
#if __JDOOM__ || __JHERETIC__
ep = atoi(argv[1]);
if(ep != 0) ep -= 1;
#else
ep = 0;
#endif

#if __JDOOM__ || __JHERETIC__
map = atoi(argv[2]); if(map != 0) map -= 1;
#else
map = atoi(argv[1]); if(map != 0) map -= 1;
#endif
#if __JHEXEN__
map = P_TranslateMapIfExists(map);
if(map == P_INVALID_LOGICAL_MAP)
{
Con_Message("Map not found.");
return false;
}
#endif

// Update game mode.
deathmatch = cfg.netDeathmatch;
noMonstersParm = cfg.netNoMonsters;
#if __JDOOM__ || __JDOOM64__ || __JHERETIC__
respawnMonsters = cfg.netRespawn;
#endif
#if __JHEXEN__
randomClassParm = cfg.netRandomClass;
#endif
cfg.jumpEnabled = cfg.netJumping;

// Use the configured network skill level for the new map.
#if __JHEXEN__
G_DeferredSetMap(cfg.netSkill, ep, map, 0/*default*/);
#else
G_DeferredNewGame(cfg.netSkill, ep, map, 0/*default*/);
#endif
return true;
}

/**
* Post a local game message.
*/
Expand Down
49 changes: 26 additions & 23 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -236,23 +236,25 @@ void NetSv_CycleToMapNum(uint map)

sprintf(tmp, "%02u", map);
#if __JDOOM64__
sprintf(cmd, "setmap 1 %u", map);
sprintf(cmd, "warp %u", map);
#elif __JDOOM__
if(gameModeBits & GM_ANY_DOOM2)
sprintf(cmd, "setmap 1 %u", map);
sprintf(cmd, "warp %u", map);
else
sprintf(cmd, "setmap %c %c", tmp[0], tmp[1]);
sprintf(cmd, "warp %c %c", tmp[0], tmp[1]);
#elif __JHERETIC__
sprintf(cmd, "setmap %c %c", tmp[0], tmp[1]);
#elif __JHEXEN__ || __JSTRIFE__
sprintf(cmd, "setmap %u", map);
sprintf(cmd, "warp %c %c", tmp[0], tmp[1]);
#elif __JHEXEN__
sprintf(cmd, "warp %u", map);
#endif

DD_Execute(false, cmd);

// In a couple of seconds, send everyone the rules of this map.
for(i = 0; i < MAXPLAYERS; ++i)
{
cycleRulesCounter[i] = 3 * TICSPERSEC;
}

cycleMode = CYCLE_IDLE;
cycleCounter = 0;
Expand Down Expand Up @@ -470,21 +472,20 @@ void NetSv_TellCycleRulesToPlayer(int destPlr)

void NetSv_MapCycleTicker(void)
{
int map, i, f;
maprule_t rules;
char msg[100];

if(!cyclingMaps) return;

// Check rules broadcasting.
{ int i;
for(i = 0; i < MAXPLAYERS; ++i)
{
if(!cycleRulesCounter[i] || !players[i].plr->inGame) continue;
if(!cycleRulesCounter[i] || !players[i].plr->inGame)
continue;

if(--cycleRulesCounter[i] == 0)
{
NetSv_TellCycleRulesToPlayer(i);
}
}
}}

cycleCounter--;

Expand All @@ -494,14 +495,14 @@ void NetSv_MapCycleTicker(void)
// Check if the current map should end.
if(cycleCounter <= 0)
{
// Test every ten seconds.
maprule_t rules;

// Test again in ten seconds time.
cycleCounter = 10 * TICSPERSEC;

map = NetSv_ScanCycle(cycleIndex, &rules);
if(map < 0)
if(NetSv_ScanCycle(cycleIndex, &rules) < 0)
{
map = NetSv_ScanCycle(cycleIndex = 0, &rules);
if(map < 0)
if(NetSv_ScanCycle(cycleIndex = 0, &rules) < 0)
{
// Hmm?! Abort cycling.
Con_Message("NetSv_CheckCycling: All of a sudden MapCycle is invalid!");
Expand All @@ -520,15 +521,19 @@ void NetSv_MapCycleTicker(void)

if(rules.usefrags)
{
int i, frags;
for(i = 0; i < MAXPLAYERS; i++)
{
if(!players[i].plr->inGame)
continue;
if((f = NetSv_GetFrags(i)) >= rules.frags)

frags = NetSv_GetFrags(i);
if(frags >= rules.frags)
{
sprintf(msg, "--- %s REACHES %i FRAGS ---", Net_GetPlayerName(i), f);
char msg[100]; sprintf(msg, "--- %s REACHES %i FRAGS ---", Net_GetPlayerName(i), frags);
NetSv_SendMessage(DDSP_ALL_PLAYERS, msg);
S_StartSound(SOUND_VICTORY, NULL);

cycleMode = CYCLE_COUNTDOWN;
cycleCounter = 15 * TICSPERSEC; // No msg for 15 secs.
break;
Expand All @@ -544,17 +549,15 @@ void NetSv_MapCycleTicker(void)
cycleCounter == 10 * TICSPERSEC ||
cycleCounter == 5 * TICSPERSEC)
{
sprintf(msg, "--- WARPING IN %i SECONDS ---",
cycleCounter / TICSPERSEC);

char msg[100]; sprintf(msg, "--- WARPING IN %i SECONDS ---", cycleCounter / TICSPERSEC);
NetSv_SendMessage(DDSP_ALL_PLAYERS, msg);
// Also, a warning sound.
S_StartSound(SOUND_COUNTDOWN, NULL);
}
else if(cycleCounter <= 0)
{
// Next map, please!
map = NetSv_ScanCycle(++cycleIndex, NULL);
int map = NetSv_ScanCycle(++cycleIndex, NULL);
if(map < 0)
{
// Must be past the end?
Expand Down

0 comments on commit cd20d82

Please sign in to comment.