Skip to content

Commit

Permalink
Fixed an issue with curses crashing due to winText not being created …
Browse files Browse the repository at this point in the history
…in dedicated mode. The dedicated mode is now checked and initialized as the very first thing.

Got rid of the old BT_ATTACK and BT_USE flags, which now tap directly into the brain, as one might say.
  • Loading branch information
skyjake committed Jul 31, 2007
1 parent 99460da commit 3fe1325
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 69 deletions.
3 changes: 3 additions & 0 deletions doomsday/engine/portable/src/b_class.c
Expand Up @@ -225,6 +225,9 @@ void B_ClearClass(bclass_t* bc)

void B_ActivateClass(bclass_t* bc, boolean doActivate)
{
if(!bc)
return;

bc->active = doActivate;
B_UpdateDeviceStateAssociations();
}
Expand Down
17 changes: 16 additions & 1 deletion doomsday/engine/portable/src/b_main.c
Expand Up @@ -242,7 +242,13 @@ void B_Register(void)
*/
void B_Init(void)
{
bclass_t* bc;
bclass_t* bc = 0;

if(isDedicated)
{
// Why sir, we are but poor folk! Them bindings are too good for us.
return;
}

B_NewClass(DEFAULT_BINDING_CLASS_NAME);

Expand Down Expand Up @@ -339,6 +345,9 @@ evbinding_t* B_BindCommand(const char* eventDesc, const char* command)
bclass_t* bc;
evbinding_t *b;

if(isDedicated)
return NULL;

// The class may be included in the descriptor.
eventDesc = B_ParseClass(eventDesc, &bc);
if(!bc)
Expand All @@ -363,6 +372,9 @@ dbinding_t* B_BindControl(const char* controlDesc, const char* device)
const char* ptr = 0;
playercontrol_t* control = 0;

if(isDedicated)
return NULL;

// The control description may begin with the local player number.
str = Str_New();
ptr = Str_CopyDelim(str, controlDesc, '-');
Expand Down Expand Up @@ -507,6 +519,9 @@ D_CMD(DeleteBindingById)

D_CMD(DefaultBindings)
{
if(isDedicated)
return false;

B_BindDefaults();

// Set the game's default bindings.
Expand Down
6 changes: 0 additions & 6 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -388,12 +388,6 @@ int DD_Main(void)
Dir_MakeAbsolute(ddBasePath);
Dir_ValidDir(ddBasePath);

if(ArgCheck("-dedicated"))
{
isDedicated = true;
Sys_ConInit();
}

if(!isDedicated)
{
if(!GL_EarlyInit())
Expand Down
7 changes: 7 additions & 0 deletions doomsday/engine/portable/src/dd_pinit.c
Expand Up @@ -200,6 +200,13 @@ boolean DD_EarlyInit(void)
{
char *outfilename = "doomsday.out";

// First order of business: are we running in dedicated mode?
if(ArgCheck("-dedicated"))
{
isDedicated = true;
Sys_ConInit();
}

// We'll redirect stdout to a log file.
DD_CheckArg("-out", &outfilename);
outFile = fopen(outfilename, "w");
Expand Down
3 changes: 3 additions & 0 deletions doomsday/engine/portable/src/sys_sdl_window.c
Expand Up @@ -218,6 +218,9 @@ uint Sys_CreateWindow(application_t *app, uint parentIDX,
{
ddwindow_t *win;

if(isDedicated)
return 1; // No use.

if(!winManagerInited)
return 0; // Window manager not initialized yet.

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_player.c
Expand Up @@ -250,7 +250,7 @@ weapontype_t P_MaybeChangeWeapon(player_t *player, weapontype_t weapon,
returnval = weapon;
}
// Is the player currently firing?
else if(!((player->plr->cmd.actions & BT_ATTACK) &&
else if(!((player->brain.attack) &&
cfg.noWeaponAutoSwitchIfFiring))
{
// Should we change weapon automatically?
Expand Down
49 changes: 17 additions & 32 deletions doomsday/plugins/common/src/p_user.c
Expand Up @@ -357,15 +357,16 @@ void P_MovePlayer(player_t *player)
{
ddplayer_t *dp = player->plr;
mobj_t *plrmo = player->plr->mo;
ticcmd_t *cmd = &player->plr->cmd;
//ticcmd_t *cmd = &player->plr->cmd;
playerbrain_t* brain = &player->brain;
classinfo_t *pClassInfo = PCLASS_INFO(player->class);
int speed;
fixed_t forwardMove;
fixed_t sideMove;

// Change the angle if possible.
/* $unifiedangles */
if(IS_SERVER && player != &players[0])
/* if(IS_SERVER && player != &players[0])
{
if(dp->fixcounter.angles == dp->fixacked.angles) // all acked?
{
Expand All @@ -377,15 +378,15 @@ void P_MovePlayer(player_t *player)
plrmo->angle = cmd->angle << 16;
dp->lookdir = cmd->pitch / (float) DDMAXSHORT *110;
}
}
}*/

// Do not let the player control movement if not onground.
onground = P_IsPlayerOnGround(player);
if(dp->flags & DDPF_CAMERA) // $democam
{
// Cameramen have a 3D thrusters!
P_Thrust3D(player, plrmo->angle, dp->lookdir,
cmd->forwardMove * 50 * 2048, cmd->sideMove * 50 * 2048);
brain->forwardMove * 50 * 2048, brain->sideMove * 50 * 2048);
}
else
{
Expand All @@ -395,12 +396,13 @@ void P_MovePlayer(player_t *player)
(cfg.airborneMovement) ? cfg.airborneMovement * 64 : 0;

// Walk -> run, run -> walk.
speed = (cmd->actions & BT_SPEED);
//speed = (cmd->actions & BT_SPEED);
speed = brain->speed;
if(cfg.alwaysRun)
speed = !speed;

forwardMove = cmd->forwardMove * pClassInfo->forwardmove[speed] * turbomul;
sideMove = cmd->sideMove * pClassInfo->sidemove[speed] * turbomul;
forwardMove = brain->forwardMove * pClassInfo->forwardmove[speed] * turbomul;
sideMove = brain->sideMove * pClassInfo->sidemove[speed] * turbomul;

if(forwardMove > pClassInfo->maxmove)
forwardMove = pClassInfo->maxmove;
Expand Down Expand Up @@ -607,7 +609,7 @@ void P_DeathThink(player_t *player)
#endif
}

if(player->plr->cmd.actions & BT_USE)
if(player->brain.use)
{
if(IS_CLIENT)
{
Expand Down Expand Up @@ -1382,16 +1384,14 @@ void P_PlayerThinkWeapons(player_t *player)

void P_PlayerThinkUse(player_t *player)
{
ticcmd_t *cmd = &player->plr->cmd;

if(IS_NETGAME && IS_SERVER && player != &players[consoleplayer])
{
// Clients send use requests instead.
return;
}

// check for use
if(cmd->actions & BT_USE)
if(player->brain.use)
{
if(!player->usedown)
{
Expand Down Expand Up @@ -1864,50 +1864,35 @@ void P_PlayerThinkUpdateControls(player_t* player)
int playerNum = player - players;
classinfo_t *pClassInfo = PCLASS_INFO(player->class);
float vel, off;
int i, speed;
int i;
boolean strafe = false;
playerbrain_t *brain = &player->brain;

// Check for speed.
P_GetControlState(playerNum, CTL_SPEED, &vel, 0);
speed = (vel != 0)? 2 : 1;
brain->speed = (vel != 0);

// Check for strafe.
P_GetControlState(playerNum, CTL_STRAFE, &vel, 0);
strafe = (vel != 0);

// Move status.
// FIXME: This is just temp stuff, ticcmd will be removed soon.
P_GetControlState(playerNum, CTL_WALK, &vel, &off);
player->plr->cmd.forwardMove = off + vel * speed;
brain->forwardMove = off + vel;
P_GetControlState(playerNum, strafe? CTL_TURN : CTL_SIDESTEP, &vel, &off);
if(strafe)
{
// Saturate.
vel = (vel > 0? 1 : vel < 0? -1 : 0);
}
player->plr->cmd.sideMove = off + vel * speed;
brain->sideMove = off + vel;

// Use.
if(P_GetImpulseControlState(playerNum, CTL_USE))
{
player->plr->cmd.actions |= BT_USE;
}
else
{
player->plr->cmd.actions &= ~BT_USE;
}
brain->use = (P_GetImpulseControlState(playerNum, CTL_USE) != 0);

// Fire.
P_GetControlState(playerNum, CTL_ATTACK, &vel, &off);
if(vel + off)
{
player->plr->cmd.actions |= BT_ATTACK;
}
else
{
player->plr->cmd.actions &= ~BT_ATTACK;
}
brain->attack = (vel + off != 0);

// Weapons.
brain->changeWeapon = WT_NOCHANGE;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/doom64tc/include/d_event.h
Expand Up @@ -52,9 +52,9 @@ extern gameaction_t gameaction;
typedef enum
{
// Press "Fire".
BT_ATTACK = 1,
// BT_ATTACK = 1,
// Use button, to open doors, activate switches.
BT_USE = 2,
//BT_USE = 2,

// Flag: game events, not really buttons.
BT_SPECIAL = 128,
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/doom64tc/src/p_pspr.c
Expand Up @@ -274,7 +274,7 @@ void C_DECL A_WeaponReady(player_t *player, pspdef_t * psp)
}

// check for autofire
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{
wminfo = WEAPON_INFO(player->readyweapon, player->class, 0);

Expand Down Expand Up @@ -303,7 +303,7 @@ void C_DECL A_ReFire(player_t *player, pspdef_t *psp)
{
// check for fire
// (if a weaponchange is pending, let it go through instead)
if((player->plr->cmd.actions & BT_ATTACK) &&
if((player->brain.attack) &&
player->pendingweapon == WT_NOCHANGE && player->health)
{
player->refire++;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/doom64tc/src/wi_stuff.c
Expand Up @@ -1132,15 +1132,15 @@ void WI_checkForAccelerate(void)
{
if(players[i].plr->ingame)
{
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{
if(!player->attackdown)
acceleratestage = 1;
player->attackdown = true;
}
else
player->attackdown = false;
if(player->plr->cmd.actions & BT_USE)
if(player->brain.use)
{
if(!player->usedown)
acceleratestage = 1;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jdoom/include/d_event.h
Expand Up @@ -52,9 +52,9 @@ extern gameaction_t gameaction;
typedef enum
{
// Press "Fire".
BT_ATTACK = 1,
//BT_ATTACK = 1,
// Use button, to open doors, activate switches.
BT_USE = 2,
//BT_USE = 2,

// Flag: game events, not really buttons.
BT_SPECIAL = 128,
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jdoom/src/p_pspr.c
Expand Up @@ -264,7 +264,7 @@ void C_DECL A_WeaponReady(player_t *player, pspdef_t * psp)
}

// check for autofire
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{
wminfo = WEAPON_INFO(player->readyweapon, player->class, 0);

Expand Down Expand Up @@ -293,7 +293,7 @@ void C_DECL A_ReFire(player_t *player, pspdef_t * psp)
{
// check for fire
// (if a weaponchange is pending, let it go through instead)
if((player->plr->cmd.actions & BT_ATTACK) &&
if((player->brain.attack) &&
player->pendingweapon == WT_NOCHANGE &&
player->health)
{
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jdoom/src/wi_stuff.c
Expand Up @@ -1420,15 +1420,15 @@ void WI_checkForAccelerate(void)
{
if(players[i].plr->ingame)
{
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{
if(!player->attackdown)
acceleratestage = 1;
player->attackdown = true;
}
else
player->attackdown = false;
if(player->plr->cmd.actions & BT_USE)
if(player->brain.use)
{
if(!player->usedown)
acceleratestage = 1;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jheretic/include/h_event.h
Expand Up @@ -62,9 +62,9 @@ extern gameaction_t gameaction;
typedef enum
{
// Press "Fire".
BT_ATTACK = 1,
//BT_ATTACK = 1,
// Use button, to open doors, activate switches.
BT_USE = 2,
//BT_USE = 2,

// Flag: game events, not really buttons.
BT_SPECIAL = 128,
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jheretic/src/in_lude.c
Expand Up @@ -483,7 +483,7 @@ void IN_CheckForSkip(void)
{
if(players->plr->ingame)
{
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{
if(!player->attackdown)
{
Expand All @@ -495,7 +495,7 @@ void IN_CheckForSkip(void)
{
player->attackdown = false;
}
if(player->plr->cmd.actions & BT_USE)
if(player->brain.use)
{
if(!player->usedown)
{
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/jheretic/src/p_pspr.c
Expand Up @@ -958,7 +958,7 @@ void C_DECL A_WeaponReady(player_t *player, pspdef_t * psp)
}

// check for autofire
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{
wminfo = WEAPON_INFO(player->readyweapon, player->class, 0);

Expand Down Expand Up @@ -994,7 +994,7 @@ void P_UpdateBeak(player_t *player, pspdef_t *psp)

void C_DECL A_BeakReady(player_t *player, pspdef_t *psp)
{
if(player->plr->cmd.actions & BT_ATTACK)
if(player->brain.attack)
{ // Chicken beak attack
player->attackdown = true;
P_SetMobjState(player->plr->mo, S_CHICPLAY_ATK1);
Expand Down Expand Up @@ -1025,7 +1025,7 @@ void C_DECL A_BeakReady(player_t *player, pspdef_t *psp)
*/
void C_DECL A_ReFire(player_t *player, pspdef_t *psp)
{
if((player->plr->cmd.actions & BT_ATTACK) &&
if((player->brain.attack) &&
player->pendingweapon == WT_NOCHANGE &&
player->health)
{
Expand Down

0 comments on commit 3fe1325

Please sign in to comment.