Ejemplo n.º 1
0
//
// CL_PredictPlayers
//
void CL_PredictPlayers (int predtic)
{
	size_t n = players.size();

	for(size_t i = 0; i < n; i++)
	{
		player_t *p = &players[i];
	
		if (!p->ingame() || !p->mo)
			continue;
			
		// GhostlyDeath -- Ignore Spectators
		if (p->spectator)
			continue;

		// Update this player if their last known status is before this tic
		if(p->tic < predtic)
		{
			if(p == &consoleplayer())
			{
				int buf = predtic%MAXSAVETICS;
				ticcmd_t *cmd = &consoleplayer().cmd;
				memcpy(cmd, &localcmds[buf], sizeof(ticcmd_t));

				p->mo->angle = cl_angle[predtic%MAXSAVETICS];
				p->mo->pitch = cl_pitch[predtic%MAXSAVETICS];
				p->viewheight = cl_viewheight[predtic%MAXSAVETICS];
				p->deltaviewheight = cl_deltaviewheight[predtic%MAXSAVETICS];
				p->mo->reactiontime = reactiontime[predtic%MAXSAVETICS];
			}
	
			CL_PredictPlayer(p);
		}
	}
}
Ejemplo n.º 2
0
//
// writeLocalCmd()
//
//   Generates a message indicating the current position and angle of the
//   consoleplayer, taking the place of ticcmds.
void NetDemo::writeLocalCmd(buf_t *netbuffer) const
{
    // Record the local player's data
    player_t *player = &consoleplayer();
    if (!player->mo)
        return;

    AActor *mo = player->mo;

    MSG_WriteByte(netbuffer, svc_netdemocap);
    MSG_WriteByte(netbuffer, player->cmd.ucmd.buttons);
    MSG_WriteByte(netbuffer, player->cmd.ucmd.impulse);
    MSG_WriteShort(netbuffer, player->cmd.ucmd.yaw);
    MSG_WriteShort(netbuffer, player->cmd.ucmd.forwardmove);
    MSG_WriteShort(netbuffer, player->cmd.ucmd.sidemove);
    MSG_WriteShort(netbuffer, player->cmd.ucmd.upmove);
    MSG_WriteShort(netbuffer, player->cmd.ucmd.pitch);

    MSG_WriteByte(netbuffer, mo->waterlevel);
    MSG_WriteLong(netbuffer, mo->x);
    MSG_WriteLong(netbuffer, mo->y);
    MSG_WriteLong(netbuffer, mo->z);
    MSG_WriteLong(netbuffer, mo->momx);
    MSG_WriteLong(netbuffer, mo->momy);
    MSG_WriteLong(netbuffer, mo->momz);
    MSG_WriteLong(netbuffer, mo->angle);
    MSG_WriteLong(netbuffer, mo->pitch);
    MSG_WriteLong(netbuffer, player->viewheight);
    MSG_WriteLong(netbuffer, player->deltaviewheight);
    MSG_WriteLong(netbuffer, player->jumpTics);
    MSG_WriteLong(netbuffer, mo->reactiontime);
    MSG_WriteByte(netbuffer, player->readyweapon);
    MSG_WriteByte(netbuffer, player->pendingweapon);
}
Ejemplo n.º 3
0
//
// CL_PredictLocalPlayer
//
// 
static void CL_PredictLocalPlayer(int predtic)
{
	player_t *player = &consoleplayer();
	
	if (!player->ingame() || !player->mo || player->tic >= predtic)
		return;

	// Restore the angle, viewheight, etc for the player
	P_SetPlayerSnapshotNoPosition(player, cl_savedsnaps[predtic % MAXSAVETICS]);

	// Copy the player's previous input ticcmd for the tic 'predtic'
	// to player.cmd so that P_MovePlayer can simulate their movement in
	// that tic
	NetCommand *netcmd = &localcmds[predtic % MAXSAVETICS];
	netcmd->toPlayer(player);

	if (!cl_predictlocalplayer)
	{
		if (predtic == gametic)
		{
			P_PlayerThink(player);
			player->mo->RunThink();
		}

		return;
	}

	if (!predicting)
		P_PlayerThink(player);
	else
		P_MovePlayer(player);

	player->mo->RunThink();
}
Ejemplo n.º 4
0
void D_SetupUserInfo(void)
{
	UserInfo* coninfo = &consoleplayer().userinfo;

	std::string netname = cl_name.str();
	if (netname.length() > MAXPLAYERNAME)
		netname.erase(MAXPLAYERNAME);

	coninfo->netname			= netname;
	coninfo->team				= D_TeamByName (cl_team.cstring()); // [Toke - Teams]
	coninfo->color				= V_GetColorFromString (NULL, cl_color.cstring());
	coninfo->gender				= D_GenderByName (cl_gender.cstring());
	coninfo->aimdist			= (fixed_t)(cl_autoaim * 16384.0);
	coninfo->unlag				= (cl_unlag != 0);
	coninfo->update_rate		= cl_updaterate;
	coninfo->predict_weapons	= (cl_predictweapons != 0);

	// sanitize the weapon switching choice
	if (cl_switchweapon < 0 || cl_switchweapon > 2)
		cl_switchweapon.ForceSet(float(WPSW_ALWAYS));
	coninfo->switchweapon	= (weaponswitch_t)cl_switchweapon.asInt();

	// Copies the updated cl_weaponpref* cvars to coninfo->weapon_prefs[]
	D_PrepareWeaponPreferenceUserInfo();
}
Ejemplo n.º 5
0
void D_SetupUserInfo(void)
{
	userinfo_t *coninfo = &consoleplayer().userinfo;

	// Save the previous weapon preferences
	weapontype_t backup_weapon_prefs[NUMWEAPONS];
	memcpy(backup_weapon_prefs, coninfo->weapon_prefs, sizeof(backup_weapon_prefs));

	memset (&consoleplayer().userinfo, 0, sizeof(userinfo_t));
	
	strncpy (coninfo->netname, cl_name.cstring(), MAXPLAYERNAME);
	coninfo->team			= D_TeamByName (cl_team.cstring()); // [Toke - Teams]
	coninfo->color			= V_GetColorFromString (NULL, cl_color.cstring());
	coninfo->skin			= R_FindSkin (cl_skin.cstring());
	coninfo->gender			= D_GenderByName (cl_gender.cstring());
	coninfo->aimdist		= (fixed_t)(cl_autoaim * 16384.0);
	coninfo->unlag			= cl_unlag;
	coninfo->update_rate	= cl_updaterate;
	coninfo->switchweapon	= (weaponswitch_t)cl_switchweapon.asInt();

	// Copies the updated cl_weaponpref* cvars to coninfo->weapon_prefs[]
	CL_PrepareWeaponPreferenceUserInfo();

	// Find which weapon preference slot was changed
	for (size_t i = 0; i < NUMWEAPONS; i++)
	{
		if (backup_weapon_prefs[i] != coninfo->weapon_prefs[i])
		{
			// slot i was changed
			weapontype_t oldweapon = backup_weapon_prefs[i];
			weapontype_t newweapon = coninfo->weapon_prefs[i];
			
			// swap the weapon in slot i with whatever slot already has newweapon
			for (size_t j = 0; j < NUMWEAPONS; j++)
			{
				if (coninfo->weapon_prefs[j] == newweapon &&  j != i)
				{
					coninfo->weapon_prefs[j] = oldweapon;
					CL_SetWeaponPreferenceCvar(j, oldweapon);
					break;
				}
			}

			break;
		}
	}
}
Ejemplo n.º 6
0
BOOL P_ActivateMobj (AActor *mobj, AActor *activator)
{
	if (mobj->flags & MF_COUNTKILL)
	{
		mobj->flags2 &= !(MF2_DORMANT | MF2_INVULNERABLE);
		return true;
	}
	else
	{
		switch (mobj->type)
		{
			case MT_SPARK:
			{
				int count = mobj->args[0];
				char sound[16];

				if (count == 0)
					count = 32;

				P_DrawSplash (count, mobj->x, mobj->y, mobj->z, mobj->angle, 1);
				sprintf (sound, "world/spark%d", 1+(M_Random() % 3));
				S_Sound (mobj, CHAN_AUTO, sound, 1, ATTN_STATIC);
				break;
			}

			case MT_FOUNTAIN:
				mobj->effects &= ~FX_FOUNTAINMASK;
				mobj->effects |= mobj->args[0] << FX_FOUNTAINSHIFT;
				break;

			case MT_SECRETTRIGGER:
				if (activator->player->mo == consoleplayer().camera)
				{
					if (mobj->args[0] <= 1)
					{
						C_MidPrint ("A secret is revealed!");
					}
					if (mobj->args[0] == 0 || mobj->args[0] == 2)
					{
						S_Sound (activator, CHAN_AUTO, "misc/secret", 1, ATTN_NORM);
					}
				}
				level.found_secrets++;
				mobj->Destroy ();
				break;

			default:
				break;
		}
	}
	return false;
}
Ejemplo n.º 7
0
//
// CL_PredictSpectator
//
//
static void CL_PredictSpectator()
{
	player_t *player = &consoleplayer();
	if (!player->spectator)
		return;
		
	predicting = true;
	
	P_PlayerThink(player);
	P_CalcHeight(player);
	
	predicting = false;
}
Ejemplo n.º 8
0
void ST_refreshBackground(void)
{
    if (st_statusbaron)
    {
        // [RH] If screen is wider than the status bar,
        //      draw stuff around status bar.
        if (FG->width > ST_WIDTH)
        {
            R_DrawBorder (0, ST_Y, ST_X, FG->height);
            R_DrawBorder (FG->width - ST_X, ST_Y, FG->width, FG->height);
        }

        BG->DrawPatch (sbar, 0, 0);

        if (sv_gametype == GM_CTF) {
            BG->DrawPatch (flagsbg, ST_FLAGSBGX, ST_FLAGSBGY);
            BG->DrawPatch (flagbox, ST_FLGBOXX, ST_FLGBOXY);
        } else if (sv_gametype == GM_COOP)
            BG->DrawPatch (armsbg, ST_ARMSBGX, ST_ARMSBGY);

        if (multiplayer)
        {
            if (!demoplayback || !democlassic) {
                // [RH] Always draw faceback with the player's color
                //		using a translation rather than a different patch.
                V_ColorMap = translationtables + (consoleplayer().id) * 256;
                BG->DrawTranslatedPatch (faceback, ST_FX, ST_FY);
            } else {
                BG->DrawPatch (faceclassic[consoleplayer().id-1], ST_FX, ST_FY);
            }
        }

        BG->Blit (0, 0, 320, 32, stnumscreen, 0, 0, 320, 32);

        if (!st_scale)
            stnumscreen->Blit (0, 0, 320, 32,
                               FG, ST_X, ST_Y, ST_WIDTH, ST_HEIGHT);
    }
}
Ejemplo n.º 9
0
// Return a string that contains the name of the player being spectated,
// or a blank string if you are looking out of your own viewpoint.
std::string SpyPlayerName(int& color) {
	color = CR_GREY;
	player_t *plyr = &displayplayer();

	if (plyr == &consoleplayer()) {
		return "";
	}

	if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) {
		color = teamTextColor(plyr->userinfo.team);
	}

	return plyr->userinfo.netname;
}
Ejemplo n.º 10
0
void ST_nameDraw (int y)
{
	player_t *plyr = &displayplayer();

	if (plyr == &consoleplayer())
		return;
	
	char *string = plyr->userinfo.netname;
	size_t x = (screen->width - V_StringWidth (string)*CleanXfac) >> 1;

	if (level.time < NameUp)
		screen->DrawTextClean (CR_GREEN, x, y, string);
	else
		screen->DrawTextCleanLuc (CR_GREEN, x, y, string);
}
Ejemplo n.º 11
0
//
// D_PrepareWeaponPreferenceUserInfo
//
// Copies the weapon order preferences from the cl_weaponpref_* cvars
// to the userinfo struct for the consoleplayer.
//
void D_PrepareWeaponPreferenceUserInfo()
{
	byte *prefs = consoleplayer().userinfo.weapon_prefs;

	for (size_t i = 0; i < NUMWEAPONS; i++)
	{
		// sanitize the weapon preferences
		if (weaponpref_cvar_map[i]->asInt() < 0)
			weaponpref_cvar_map[i]->ForceSet(0.0f);
		if (weaponpref_cvar_map[i]->asInt() >= NUMWEAPONS)
			weaponpref_cvar_map[i]->ForceSet(float(NUMWEAPONS - 1));

		prefs[i] = weaponpref_cvar_map[i]->asInt();
	}
}
Ejemplo n.º 12
0
void RenderAutomap()
{
	size_t i;

	glDisable(GL_TEXTURE_2D);

	glColor4f(0.2,0.2,0,1);
	DrawQuad(0,0,1,1);

	glColor4f(1,1,1,1);

	glPushMatrix();

	glTranslatef(0.5, 0.5, 0);

	glScalef(-0.001, 0.001, 0.001);

	AActor *mo = consoleplayer().mo;
	if(mo)
		glTranslatef(FIXED2FLOAT(mo->x), FIXED2FLOAT(mo->y), 0);
	glRotatef(180, 0, 0, 1);

	glBegin(GL_LINES);

	// grid

	// walls
	for(i = 0; i < numlines; i++)
	{
		if (!(lines[i].flags & ML_MAPPED))
			continue;

		glVertex2f(FIXED2FLOAT(lines[i].v1->x), FIXED2FLOAT(lines[i].v1->y));
		glVertex2f(FIXED2FLOAT(lines[i].v2->x), FIXED2FLOAT(lines[i].v2->y));
	}

	// players
	for (i = 0; i < players.size(); i++)
	{
	}

	// things

	glEnd();

	glPopMatrix();
}
Ejemplo n.º 13
0
//
// CL_PredicMove
//
void CL_PredictMove (void)
{
	if (noservermsgs)
		return;

	player_t *p = &consoleplayer();

	if (!p->tic || !p->mo)
		return;

	// Save player angle, viewheight,deltaviewheight and jumpTics.
	// Will use it later to predict movements
	int buf = gametic%MAXSAVETICS;
	
	cl_angle[buf] = p->mo->angle;
	cl_pitch[buf] = p->mo->pitch;
	cl_viewheight[buf] = p->viewheight;
	cl_deltaviewheight[buf] = p->deltaviewheight;
	cl_jumpTics[buf] = p->jumpTics;
	cl_reactiontime[buf] = p->mo->reactiontime;

	// Disable sounds, etc, during prediction
	predicting = true;

	// Set predictable items to their last received positions
	CL_ResetPlayers();
	CL_ResetSectors();

	int predtic = gametic - MAXSAVETICS;

	if(predtic < 0)
		predtic = 0;

	// Predict each tic
	while(predtic < gametic)
	{
		CL_PredictPlayers(predtic);
		CL_PredictSectors(predtic);

		++predtic;
	}

	predicting = false;

	CL_PredictPlayers(predtic);
	CL_PredictSectors(predtic);
}
Ejemplo n.º 14
0
//
// C_DoSpectatorKey
//
// [SL] 2012-09-14 - Handles the hard-coded key bindings used while spectating
// or during NetDemo playback.  Returns false if the key pressed is not
// bound to any spectating command such as spynext.
//
bool C_DoSpectatorKey (event_t *ev)
{
	if (!consoleplayer().spectator && !netdemo.isPlaying() && !netdemo.isPaused())
		return false;

	if (ev->type == ev_keydown && ev->data1 == KEY_MWHEELUP)
	{
		AddCommandString("spyprev");
		return true;
	}
	if (ev->type == ev_keydown && ev->data1 == KEY_MWHEELDOWN)
	{
		AddCommandString("spynext");
		return true;
	}

	return false;
}
Ejemplo n.º 15
0
//
//	[Toke - CTF] CTF_CarryFlag
//	Spawns a flag on a players location and links the flag to the player
//
void CTF_CarryFlag (player_t &player, flag_t flag)
{
	if (!validplayer(player))
		return;

	player.flags[flag] = true;
	CTFdata[flag].flagger = player.id;
	CTFdata[flag].state = flag_carried;

	// spawn visible flags on other players
	if(&player != &consoleplayer())
	{
		AActor *actor = new AActor(0, 0, 0, flag_table[flag][flag_carried]);
		CTFdata[flag].actor = actor->ptr();

		CTF_MoveFlags();
	}
}
Ejemplo n.º 16
0
/* Original redscreen palette method - replaces ZDoom method - ML       */
void ST_doPaletteStuff(void)
{

    int		palette;
    byte*	pal;
    int		cnt;
    int		bzc;

    player_t *plyr = &consoleplayer();

    cnt = plyr->damagecount;

    if (plyr->powers[pw_strength])
    {
        // slowly fade the berzerk out
        bzc = 12 - (plyr->powers[pw_strength]>>6);

        if (bzc > cnt)
            cnt = bzc;
    }
Ejemplo n.º 17
0
int ST_calcPainOffset(void)
{
    int 		health;
    static int	lastcalc;
    static int	oldhealth = -1;

    health = consoleplayer().health;

    if(health < -1)
        health = -1;
    else if(health > 100)
        health = 100;

    if (health != oldhealth)
    {
        lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101);
        oldhealth = health;
    }

    return lastcalc;
}
Ejemplo n.º 18
0
/* Original redscreen palette method - replaces ZDoom method - ML       */
void ST_doPaletteStuff(void)
{

    int		palette;
    byte*	pal;
    float	cnt;
    int		bzc;

	player_t *plyr = &consoleplayer();

    cnt = (float)plyr->damagecount;
	if (!multiplayer || sv_allowredscreen)
		cnt *= r_painintensity;

    if (plyr->powers[pw_strength])
    {
	// slowly fade the berzerk out
        bzc = 12 - (plyr->powers[pw_strength]>>6);

        if (bzc > cnt)
            cnt = bzc;
    }
Ejemplo n.º 19
0
void ST_AdjustStatusBarScale(bool scale)
{
	if (scale)
	{
		// Scale status bar height to screen.
		ST_HEIGHT = (32 * screen->height) / 200;
		// [AM] Scale status bar width according to height, unless there isn't
		//      enough room for it.  Fixes widescreen status bar scaling.
		// [ML] A couple of minor changes for true 4:3 correctness...
		ST_WIDTH = ST_HEIGHT*10;
		if (!screen->isProtectedRes())
        {
            ST_WIDTH = SquareWidth;
        }
	}
	else
	{
		// Do not stretch status bar
		ST_WIDTH = 320;
		ST_HEIGHT = 32;
	}

	if (consoleplayer().spectator && displayplayer_id == consoleplayer_id)
	{
		ST_X = 0;
		ST_Y = screen->height;
	}
	else
	{
		ST_X = (screen->width-ST_WIDTH)/2;
		ST_Y = screen->height - ST_HEIGHT;
	}

	setsizeneeded = true;
	st_firsttime = true;
}
Ejemplo n.º 20
0
// Returns a string that contains the current warmup state.
std::string Warmup(int& color)
{
	color = CR_GREY;
	player_t *dp = &displayplayer();
	player_t *cp = &consoleplayer();

	::Warmup::status_t wstatus = warmup.get_status();

	if (wstatus == ::Warmup::WARMUP)
	{
		if (dp->spectator)
			return "Warmup: You are spectating";
		else if (dp->ready)
		{
			color = CR_GREEN;
			if (dp == cp)
				return "Warmup: You are ready";
			else
				return "Warmup: This player is ready";
		}
		else
		{
			color = CR_RED;
			if (dp == cp)
				return "Warmup: You are not ready";
			else
				return "Warmup: This player is not ready";
		}
	}
	else if (wstatus == ::Warmup::COUNTDOWN || wstatus == ::Warmup::FORCE_COUNTDOWN)
	{
		color = CR_GOLD;
		return "Match is about to start...";
	}
	return "";
}
Ejemplo n.º 21
0
//
// This is a not-very-pretty routine which handles
//	the face states and their timing.
// the precedence of expressions is:
//	dead > evil grin > turned head > straight ahead
//
void ST_updateFaceWidget(void)
{
    int 		i;
    angle_t 	badguyangle;
    angle_t 	diffang;
    static int	lastattackdown = -1;
    static int	priority = 0;
    BOOL	 	doevilgrin;

    player_t *plyr = &consoleplayer();

    if (priority < 10)
    {
        // dead
        if (!plyr->health)
        {
            priority = 9;
            st_faceindex = ST_DEADFACE;
            st_facecount = 1;
        }
    }

    if (priority < 9)
    {
        if (plyr->bonuscount)
        {
            // picking up bonus
            doevilgrin = false;

            for (i=0; i<NUMWEAPONS; i++)
            {
                if (oldweaponsowned[i] != plyr->weaponowned[i])
                {
                    doevilgrin = true;
                    oldweaponsowned[i] = plyr->weaponowned[i];
                }
            }
            if (doevilgrin)
            {
                // evil grin if just picked up weapon
                priority = 8;
                st_facecount = ST_EVILGRINCOUNT;
                st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
            }
        }

    }

    if (priority < 8)
    {
        if (plyr->damagecount
                && plyr->attacker
                && plyr->attacker != plyr->mo)
        {
            // being attacked
            priority = 7;

            if (st_oldhealth - plyr->health > ST_MUCHPAIN)
            {
                st_facecount = ST_TURNCOUNT;
                st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
            }
            else
            {
                badguyangle = R_PointToAngle2(plyr->mo->x,
                                              plyr->mo->y,
                                              plyr->attacker->x,
                                              plyr->attacker->y);

                if (badguyangle > plyr->mo->angle)
                {
                    // whether right or left
                    diffang = badguyangle - plyr->mo->angle;
                    i = diffang > ANG180;
                }
                else
                {
                    // whether left or right
                    diffang = plyr->mo->angle - badguyangle;
                    i = diffang <= ANG180;
                } // confusing, aint it?


                st_facecount = ST_TURNCOUNT;
                st_faceindex = ST_calcPainOffset();

                if (diffang < ANG45)
                {
                    // head-on
                    st_faceindex += ST_RAMPAGEOFFSET;
                }
                else if (i)
                {
                    // turn face right
                    st_faceindex += ST_TURNOFFSET;
                }
                else
                {
                    // turn face left
                    st_faceindex += ST_TURNOFFSET+1;
                }
            }
        }
    }

    if (priority < 7)
    {
        // getting hurt because of your own damn stupidity
        if (plyr->damagecount)
        {
            if (st_oldhealth - plyr->health > ST_MUCHPAIN)
            {
                priority = 7;
                st_facecount = ST_TURNCOUNT;
                st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;
            }
            else
            {
                priority = 6;
                st_facecount = ST_TURNCOUNT;
                st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
            }

        }

    }

    if (priority < 6)
    {
        // rapid firing
        if (plyr->attackdown)
        {
            if (lastattackdown==-1)
                lastattackdown = ST_RAMPAGEDELAY;
            else if (!--lastattackdown)
            {
                priority = 5;
                st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;
                st_facecount = 1;
                lastattackdown = 1;
            }
        }
        else
            lastattackdown = -1;

    }

    if (priority < 5)
    {
        // invulnerability
        if ((plyr->cheats & CF_GODMODE)
                || plyr->powers[pw_invulnerability])
        {
            priority = 4;

            st_faceindex = ST_GODFACE;
            st_facecount = 1;

        }
    }

    // look left or look right if the facecount has timed out
    if (!st_facecount)
    {
        st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3);
        st_facecount = ST_STRAIGHTFACECOUNT;
        priority = 0;
    }

    st_facecount--;
}
Ejemplo n.º 22
0
// Respond to keyboard input events, intercept cheats.
// [RH] Cheats eatkey the last keypress used to trigger them
bool ST_Responder (event_t *ev)
{
    player_t *plyr = &consoleplayer();
    bool eatkey = false;
    int i;

    // Filter automap on/off.
    if (ev->type == ev_keyup && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
    {
        switch(ev->data1)
        {
        case AM_MSGENTERED:
            st_gamestate = AutomapState;
            st_firsttime = true;
            break;

        case AM_MSGEXITED:
            st_gamestate = FirstPersonState;
            break;
        }
    }

    // if a user keypress...
    else if (ev->type == ev_keydown)
    {
        // 'dqd' cheat for toggleable god mode
        if (cht_CheckCheat(&cheat_god, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            // [Russell] - give full health
            plyr->mo->health = deh.StartHealth;
            plyr->health = deh.StartHealth;

            AddCommandString("god");

            // Net_WriteByte (DEM_GENERICCHEAT);
            // Net_WriteByte (CHT_IDDQD);
            eatkey = true;
        }

        // 'fa' cheat for killer f*****g arsenal
        else if (cht_CheckCheat(&cheat_ammonokey, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            Printf(PRINT_HIGH, "Ammo (No keys) Added\n");

            plyr->armorpoints = deh.FAArmor;
            plyr->armortype = deh.FAAC;

            weapontype_t pendweap = plyr->pendingweapon;
            for (i = 0; i<NUMWEAPONS; i++)
                P_GiveWeapon (plyr, (weapontype_t)i, false);
            plyr->pendingweapon = pendweap;

            for (i=0; i<NUMAMMO; i++)
                plyr->ammo[i] = plyr->maxammo[i];

            MSG_WriteMarker(&net_buffer, clc_cheatpulse);
            MSG_WriteByte(&net_buffer, 1);

            eatkey = true;
        }

        // 'kfa' cheat for key full ammo
        else if (cht_CheckCheat(&cheat_ammo, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            Printf(PRINT_HIGH, "Very Happy Ammo Added\n");

            plyr->armorpoints = deh.KFAArmor;
            plyr->armortype = deh.KFAAC;

            weapontype_t pendweap = plyr->pendingweapon;
            for (i = 0; i<NUMWEAPONS; i++)
                P_GiveWeapon (plyr, (weapontype_t)i, false);
            plyr->pendingweapon = pendweap;

            for (i=0; i<NUMAMMO; i++)
                plyr->ammo[i] = plyr->maxammo[i];

            for (i=0; i<NUMCARDS; i++)
                plyr->cards[i] = true;

            MSG_WriteMarker(&net_buffer, clc_cheatpulse);
            MSG_WriteByte(&net_buffer, 2);

            eatkey = true;
        }
        // [Russell] - Only doom 1/registered can have idspispopd and
        // doom 2/final can have idclip
        else if (cht_CheckCheat(&cheat_noclip, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            if ((gamemode != shareware) && (gamemode != registered) &&
                    (gamemode != retail))
                return false;

            AddCommandString("noclip");

            // Net_WriteByte (DEM_GENERICCHEAT);
            // Net_WriteByte (CHT_NOCLIP);
            eatkey = true;
        }
        else if (cht_CheckCheat(&cheat_commercial_noclip, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            if (gamemode != commercial)
                return false;

            AddCommandString("noclip");

            // Net_WriteByte (DEM_GENERICCHEAT);
            // Net_WriteByte (CHT_NOCLIP);
            eatkey = true;
        }
        // 'behold?' power-up cheats
        for (i=0; i<6; i++)
        {
            if (cht_CheckCheat(&cheat_powerup[i], (char)ev->data2))
            {
                if (CheckCheatmode ())
                    return false;

                Printf(PRINT_HIGH, "Power-up toggled\n");
                if (!plyr->powers[i])
                    P_GivePower( plyr, i);
                else if (i!=pw_strength)
                    plyr->powers[i] = 1;
                else
                    plyr->powers[i] = 0;

                MSG_WriteMarker(&net_buffer, clc_cheatpulse);
                MSG_WriteByte(&net_buffer, 3);
                MSG_WriteByte(&net_buffer, (byte)i);

                eatkey = true;
            }
        }

        // 'behold' power-up menu
        if (cht_CheckCheat(&cheat_powerup[6], (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            Printf (PRINT_HIGH, "%s\n", STSTR_BEHOLD);

        }

        // 'choppers' invulnerability & chainsaw
        else if (cht_CheckCheat(&cheat_choppers, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            Printf(PRINT_HIGH, "... Doesn't suck - GM\n");
            plyr->weaponowned[wp_chainsaw] = true;

            MSG_WriteMarker(&net_buffer, clc_cheatpulse);
            MSG_WriteByte(&net_buffer, 4);

            eatkey = true;
        }

        // 'clev' change-level cheat
        else if (cht_CheckCheat(&cheat_clev, (char)ev->data2))
        {
            if (CheckCheatmode ())
                return false;

            char buf[16];
            //char *bb;

            cht_GetParam(&cheat_clev, buf);
            buf[2] = 0;

            // [ML] Chex mode: always set the episode number to 1.
            // FIXME: This is probably a horrible hack, it sure looks like one at least
            if (gamemode == retail_chex)
                sprintf(buf,"1%c",buf[1]);

            sprintf (buf + 3, "map %s\n", buf);
            AddCommandString (buf + 3);
            eatkey = true;
        }

        // 'mypos' for player position
        else if (cht_CheckCheat(&cheat_mypos, (char)ev->data2))
        {
            AddCommandString ("toggle idmypos");
            eatkey = true;
        }

        // 'idmus' change-music cheat
        else if (cht_CheckCheat(&cheat_mus, (char)ev->data2))
        {
            char buf[16];

            cht_GetParam(&cheat_mus, buf);
            buf[2] = 0;

            sprintf (buf + 3, "idmus %s\n", buf);
            AddCommandString (buf + 3);
            eatkey = true;
        }
    }

    return eatkey;
}
Ejemplo n.º 23
0
//
// This cycles through the demo sequences.
//
void D_DoAdvanceDemo (void)
{
	const char *pagename = NULL;

	consoleplayer().playerstate = PST_LIVE;	// not reborn
	advancedemo = false;
	usergame = false;				// no save / end game here
	paused = false;
	gameaction = ga_nothing;

    // [Russell] - Old demo sequence used in original games, zdoom's
    // dynamic one was too dynamic for its own good
    // [Nes] - Newer demo sequence with better flow.
    if (W_CheckNumForName("DEMO4") >= 0 && gamemode != retail_chex)
        demosequence = (demosequence+1)%8;
    else
        demosequence = (demosequence+1)%6;

    switch (demosequence)
    {
        case 0:
            if (gameinfo.flags & GI_MAPxx)
                pagetic = TICRATE * 11;
            else
                pagetic = 170;

            gamestate = GS_DEMOSCREEN;
            pagename = gameinfo.titlePage;

            S_StartMusic(gameinfo.titleMusic);

            break;
        case 1:
            G_DeferedPlayDemo("DEMO1");

            break;
        case 2:
            pagetic = 200;
            gamestate = GS_DEMOSCREEN;
            pagename = gameinfo.creditPage1;

            break;
        case 3:
            G_DeferedPlayDemo("DEMO2");

            break;
        case 4:
            gamestate = GS_DEMOSCREEN;

            if ((gameinfo.flags & GI_MAPxx) || (gameinfo.flags & GI_MENUHACK_RETAIL))
            {
				if (gameinfo.flags & GI_MAPxx)
					pagetic = TICRATE * 11;
				else
					pagetic = 170;
                pagename = gameinfo.titlePage;
                S_StartMusic(gameinfo.titleMusic);
            }
            else
            {
                pagetic = 200;
				if (gamemode == retail_chex)	// [ML] Chex mode just cycles this screen
					pagename = gameinfo.creditPage1;
				else
					pagename = gameinfo.creditPage2;
            }

            break;
        case 5:
            G_DeferedPlayDemo("DEMO3");

            break;
        case 6:
            pagetic = 200;
            gamestate = GS_DEMOSCREEN;
            pagename = gameinfo.creditPage2;

            break;
        case 7:
            G_DeferedPlayDemo("DEMO4");

            break;
    }

    // [Russell] - Still need this toilet humor for now unfortunately
	if (pagename)
	{
		Texture::TextureSourceType textype =
				(gameinfo.flags & GI_PAGESARERAW) ? Texture::TEX_RAW : Texture::TEX_PATCH;
		page_texhandle = texturemanager.getHandle(pagename, textype);
	}
}
Ejemplo n.º 24
0
//
// G_BuildTiccmd
// Builds a ticcmd from all of the available inputs
// or reads it from the demo buffer.
// If recording a demo, write it out
//
void G_BuildTiccmd (ticcmd_t *cmd)
{
	int 		strafe;
	int 		speed;
	int 		tspeed;
	int 		forward;
	int 		side;
	int			look;
	int			fly;

	ticcmd_t	*base;

	base = I_BaseTiccmd (); 			// empty, or external driver

	memcpy (cmd,base,sizeof(*cmd));

	strafe = Actions[ACTION_STRAFE];
	speed = Actions[ACTION_SPEED];
	if (cl_run)
		speed ^= 1;

	forward = side = look = fly = 0;
	
	// GhostlyDeath -- USE takes us out of spectator mode
	if ((&consoleplayer())->spectator && Actions[ACTION_USE] && connected)
	{
		MSG_WriteMarker(&net_buffer, clc_spectate);
		MSG_WriteByte(&net_buffer, false);
	}
 
	// [RH] only use two stage accelerative turning on the keyboard
	//		and not the joystick, since we treat the joystick as
	//		the analog device it is.
	if ((Actions[ACTION_LEFT]) || (Actions[ACTION_RIGHT]))
		turnheld += 1;
	else
		turnheld = 0;

	if (turnheld < SLOWTURNTICS)
		tspeed = 2; 			// slow turn
	else
		tspeed = speed;

	// let movement keys cancel each other out
	if (strafe)
	{
		if (Actions[ACTION_RIGHT])
			side += sidemove[speed];
		if (Actions[ACTION_LEFT])
			side -= sidemove[speed];
	}
	else
	{
		if (Actions[ACTION_RIGHT])
			cmd->ucmd.yaw -= angleturn[tspeed];
		if (Actions[ACTION_LEFT])
			cmd->ucmd.yaw += angleturn[tspeed];
	}

	if (Actions[ACTION_LOOKUP])
		look += lookspeed[speed];
	if (Actions[ACTION_LOOKDOWN])
		look -= lookspeed[speed];

	if (Actions[ACTION_MOVEUP])
		fly += flyspeed[speed];
	if (Actions[ACTION_MOVEDOWN])
		fly -= flyspeed[speed];

	if (Actions[ACTION_KLOOK])
	{
		if (Actions[ACTION_FORWARD])
			look += lookspeed[speed];
		if (Actions[ACTION_BACK])
			look -= lookspeed[speed];
	}
	else
	{
		if (Actions[ACTION_FORWARD])
			forward += forwardmove[speed];
		if (Actions[ACTION_BACK])
			forward -= forwardmove[speed];
	}

	if (Actions[ACTION_MOVERIGHT])
		side += sidemove[speed];
	if (Actions[ACTION_MOVELEFT])
		side -= sidemove[speed];

	// buttons
	if (Actions[ACTION_ATTACK] && ConsoleState == c_up && !headsupactive) // john - only add attack when console up
		cmd->ucmd.buttons |= BT_ATTACK;

	if (Actions[ACTION_USE])
		cmd->ucmd.buttons |= BT_USE;

	if (Actions[ACTION_JUMP])
		cmd->ucmd.buttons |= BT_JUMP;

	// [RH] Handle impulses. If they are between 1 and 7,
	//		they get sent as weapon change events.
	if (Impulse >= 1 && Impulse <= 7)
	{
		cmd->ucmd.buttons |= BT_CHANGE;
		cmd->ucmd.buttons |= (Impulse - 1) << BT_WEAPONSHIFT;
	}
	else
	{
		cmd->ucmd.impulse = Impulse;
	}
	Impulse = 0;

	// [RH] Scale joystick moves to full range of allowed speeds
	if (strafe || lookstrafe)
		side += (MAXPLMOVE * joyxmove) / 256;
	else
		cmd->ucmd.yaw -= (angleturn[1] * joyxmove) / 256;

	// [RH] Scale joystick moves over full range
	if (Actions[ACTION_MLOOK])
	{
		if (invertmouse)
			look -= (joyymove * 32767) / 256;
		else
			look += (joyymove * 32767) / 256;
	}
	else
	{
		forward += (MAXPLMOVE * joyymove) / 256;
	}

	if ((Actions[ACTION_MLOOK]) || (cl_mouselook && sv_freelook))
	{
		int val;

		val = (int)((float)(mousey * 16) * m_pitch);
		if (invertmouse)
			look -= val;
		else
			look += val;
	}
	else
	{
		if (novert == 0) // [Toke - Mouse] acts like novert.exe
		{
			forward += (int)((float)mousey * m_forward);
		}
	}

	if (sendcenterview)
	{
		sendcenterview = false;
		look = -32768;
	}
	else
	{
		if (look > 32767)
			look = 32767;
		else if (look < -32767)
			look = -32767;
	}

	if (strafe || lookstrafe)
		side += (int)((float)mousex * m_side);
	else
		cmd->ucmd.yaw -= (int)((float)(mousex*0x8) * m_yaw);

	mousex = mousey = 0;

	if (forward > MAXPLMOVE)
		forward = MAXPLMOVE;
	else if (forward < -MAXPLMOVE)
		forward = -MAXPLMOVE;
	if (side > MAXPLMOVE)
		side = MAXPLMOVE;
	else if (side < -MAXPLMOVE)
		side = -MAXPLMOVE;

	cmd->ucmd.forwardmove += forward;
	cmd->ucmd.sidemove += side;
	cmd->ucmd.pitch = look;
	cmd->ucmd.upmove = fly;

	// special buttons
	if (sendpause)
	{
		sendpause = false;
		cmd->ucmd.buttons = BT_SPECIAL | BTS_PAUSE;
	}

	if (sendsave)
	{
		sendsave = false;
		cmd->ucmd.buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT);
	}

	cmd->ucmd.forwardmove <<= 8;
	cmd->ucmd.sidemove <<= 8;

	// [RH] 180-degree turn overrides all other yaws
	if (turntick) {
		turntick--;
		cmd->ucmd.yaw = (ANG180 / TURN180_TICKS) >> 16;
	}

	joyxmove = 0;
	joyymove = 0;
}
Ejemplo n.º 25
0
void cht_Give (player_t *player, const char *name)
{
	BOOL giveall;
	int i;
	gitem_t *it;

	if (player != &consoleplayer())
		Printf (PRINT_HIGH, "%s is a cheater: give %s\n", player->userinfo.netname, name);

	if (stricmp (name, "all") == 0)
		giveall = true;
	else
		giveall = false;

	if (giveall || strnicmp (name, "health", 6) == 0) {
		int h;

		if (0 < (h = atoi (name + 6))) {
			if (player->mo) {
				player->mo->health += h;
	  			player->health = player->mo->health;
			} else {
				player->health += h;
			}
		} else {
			if (player->mo)
				player->mo->health = deh.GodHealth;
	  
			player->health = deh.GodHealth;
		}

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "backpack") == 0) {
		if (!player->backpack) {
			for (i=0 ; i<NUMAMMO ; i++)
			player->maxammo[i] *= 2;
			player->backpack = true;
		}
		for (i=0 ; i<NUMAMMO ; i++)
			P_GiveAmmo (player, (ammotype_t)i, 1);

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "weapons") == 0) {
		weapontype_t pendweap = player->pendingweapon;
		for (i = 0; i<NUMWEAPONS; i++)
			P_GiveWeapon (player, (weapontype_t)i, false);
		player->pendingweapon = pendweap;

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "ammo") == 0) {
		for (i=0;i<NUMAMMO;i++)
			player->ammo[i] = player->maxammo[i];

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "armor") == 0) {
		player->armorpoints = 200;
		player->armortype = 2;

		if (!giveall)
			return;
	}

	if (giveall || stricmp (name, "keys") == 0) {
		for (i=0;i<NUMCARDS;i++)
			player->cards[i] = true;

		if (!giveall)
			return;
	}

	if (giveall)
		return;

	it = FindItem (name);
	if (!it) {
		it = FindItemByClassname (name);
		if (!it) {
			if (player == &consoleplayer())
				Printf (PRINT_HIGH, "Unknown item\n");
			return;
		}
	}

	if (it->flags & IT_AMMO) {
		int howmuch;

	/*	if (argc == 3)
			howmuch = atoi (argv[2]);
		else */
			howmuch = it->quantity;

		P_GiveAmmo (player, (ammotype_t)it->offset, howmuch);
	} else if (it->flags & IT_WEAPON) {
		P_GiveWeapon (player, (weapontype_t)it->offset, 0);
	} else if (it->flags & IT_KEY) {
		P_GiveCard (player, (card_t)it->offset);
	} else if (it->flags & IT_POWERUP) {
		P_GivePower (player, it->offset);
	} else if (it->flags & IT_ARMOR) {
		P_GiveArmor (player, it->offset);
	}
}
Ejemplo n.º 26
0
void G_InitNew (const char *mapname)
{
    size_t i;

    // [RH] Remove all particles
    R_ClearParticles ();

    for (i = 0; i < players.size(); i++)
    {
        players[i].mo = AActor::AActorPtr();
        players[i].camera = AActor::AActorPtr();
        players[i].attacker = AActor::AActorPtr();
    }

    if (!savegamerestore)
        G_ClearSnapshots ();

    // [RH] Mark all levels as not visited
    if (!savegamerestore)
    {
        for (i = 0; i < wadlevelinfos.size(); i++)
            wadlevelinfos[i].flags &= ~LEVEL_VISITED;

        for (i = 0; LevelInfos[i].mapname[0]; i++)
            LevelInfos[i].flags &= ~LEVEL_VISITED;
    }

    cvar_t::UnlatchCVars ();

    if (sv_skill > sk_nightmare)
        sv_skill.Set (sk_nightmare);
    else if (sv_skill < sk_baby)
        sv_skill.Set (sk_baby);

    cvar_t::UnlatchCVars ();

    if (paused)
    {
        paused = false;
        S_ResumeSound ();
    }

    // If were in chasecam mode, clear out // [Toke - fix]
    if ((consoleplayer().cheats & CF_CHASECAM))
    {
        consoleplayer().cheats &= ~CF_CHASECAM;
    }

    // [RH] If this map doesn't exist, bomb out
    if (W_CheckNumForName (mapname) == -1)
    {
        I_Error ("Could not find map %s\n", mapname);
    }

    if (sv_skill == sk_nightmare || sv_monstersrespawn)
        respawnmonsters = true;
    else
        respawnmonsters = false;

    bool wantFast = sv_fastmonsters || (sv_skill == sk_nightmare);
    if (wantFast != isFast)
    {
        if (wantFast)
        {
            for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++)
                states[i].tics >>= 1;
            mobjinfo[MT_BRUISERSHOT].speed = 20*FRACUNIT;
            mobjinfo[MT_HEADSHOT].speed = 20*FRACUNIT;
            mobjinfo[MT_TROOPSHOT].speed = 20*FRACUNIT;
        }
        else
        {
            for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++)
                states[i].tics <<= 1;
            mobjinfo[MT_BRUISERSHOT].speed = 15*FRACUNIT;
            mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT;
            mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT;
        }
        isFast = wantFast;
    }
Ejemplo n.º 27
0
//
// D_Display
//  draw current display, possibly wiping it from the previous
//
void D_Display (void)
{
	if (nodrawers)
		return; 				// for comparative timing / profiling

	BEGIN_STAT(D_Display);

	// [RH] change the screen mode if needed
	if (setmodeneeded)
	{
		// Change screen mode.
		if (!V_SetResolution (NewWidth, NewHeight, NewBits))
			I_FatalError ("Could not change screen mode");

		// Recalculate various view parameters.
		setsizeneeded = true;
		// Trick status bar into rethinking its position
		st_scale.Callback ();
		// Refresh the console.
		C_NewModeAdjust ();
	}

	// [AM] Moved to below setmodeneeded so we have accurate screen size info.
	if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera)
	{
		if (consoleplayer().camera->player)
			R_SetFOV(consoleplayer().camera->player->fov, setmodeneeded || setsizeneeded);
		else
			R_SetFOV(90.0f, setmodeneeded || setsizeneeded);
	}

	// change the view size if needed
	if (setsizeneeded)
	{
		R_ExecuteSetViewSize ();
		setmodeneeded = false;
	}

	I_BeginUpdate ();

	// [RH] Allow temporarily disabling wipes
	if (NoWipe)
	{
		NoWipe--;
		wipegamestate = gamestate;
	}
	else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE)
	{
		wipegamestate = gamestate;
		Wipe_Start();
		wiping_screen = true;
	}

	switch (gamestate)
	{
		case GS_FULLCONSOLE:
		case GS_DOWNLOAD:
		case GS_CONNECTING:
        case GS_CONNECTED:
			C_DrawConsole ();
			M_Drawer ();
			I_FinishUpdate ();
			return;

		case GS_LEVEL:
			if (!gametic)
				break;

			V_DoPaletteEffects();
			if (viewactive)
				R_RenderPlayerView(&displayplayer());
			if (automapactive)
				AM_Drawer();
			V_RestorePalettes();
			R_DrawViewBorder();
			C_DrawMid ();
			C_DrawGMid();
			CTF_DrawHud ();
			ST_Drawer ();
			HU_Drawer ();
			break;

		case GS_INTERMISSION:
			if (viewactive)
				R_RenderPlayerView(&displayplayer());
			C_DrawMid ();
			CTF_DrawHud ();
			WI_Drawer ();
			HU_Drawer ();
			break;

		case GS_FINALE:
			F_Drawer ();
			break;

		case GS_DEMOSCREEN:
			D_PageDrawer ();
			break;

	default:
	    break;
	}

	// draw pause pic
	if (paused && !menuactive)
	{
		const Texture* texture = R_LoadTexture("M_PAUSE");
		int x = (screen->width - texture->getWidth() * CleanXfac) / 2;
		int y = (automapactive && !viewactive) ? 4 : viewwindowy + 4;
		screen->DrawTextureCleanNoMove(texture, x, y);
	}

	// [RH] Draw icon, if any
	if (D_DrawIcon)
	{
		texhandle_t texhandle = texturemanager.getHandle(D_DrawIcon, Texture::TEX_PATCH);
		const Texture* texture = texturemanager.getTexture(texhandle);
		D_DrawIcon = NULL;

		int x = 160 - texture->getWidth() / 2;
		int y = 100 - texture->getHeight() / 2;
		screen->DrawTextureIndirect(texture, x, y);
		NoWipe = 10;
	}

	if (wiping_screen)
		Wipe_Drawer();

	C_DrawConsole();	// draw console
	M_Drawer();			// menu is drawn even on top of everything
	I_FinishUpdate();	// page flip or blit buffer

	END_STAT(D_Display);
}
Ejemplo n.º 28
0
void ST_updateWidgets(void)
{
    static int	largeammo = 1994; // means "n/a"
    int 		i;

    player_t *plyr = &consoleplayer();

    // must redirect the pointer if the ready weapon has changed.
    //	if (w_ready.data != plyr->readyweapon)
    //	{
    if (weaponinfo[plyr->readyweapon].ammo == am_noammo)
        w_ready.num = &largeammo;
    else
        w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo];
    //{
    // static int tic=0;
    // static int dir=-1;
    // if (!(tic&15))
    //	 plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir;
    // if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100)
    //	 dir = 1;
    // tic++;
    // }
    w_ready.data = plyr->readyweapon;

    st_health = plyr->health;
    st_armor = plyr->armorpoints;

    for(i = 0; i < 4; i++)
    {
        st_ammo[i] = plyr->ammo[i];
        st_maxammo[i] = plyr->maxammo[i];
    }
    for(i = 0; i < 6; i++)
    {
        // denis - longwinded so compiler optimization doesn't skip it (fault in my gcc?)
        if(plyr->weaponowned[i+1])
            st_weaponowned[i] = 1;
        else
            st_weaponowned[i] = 0;
    }

    st_current_ammo = plyr->ammo[weaponinfo[plyr->readyweapon].ammo];
    // if (*w_ready.on)
    //	STlib_updateNum(&w_ready, true);
    // refresh weapon change
    //	}

    // update keycard multiple widgets
    for (i=0; i<3; i++)
    {
        keyboxes[i] = plyr->cards[i] ? i : -1;

        // [RH] show multiple keys per box, too
        if (plyr->cards[i+3])
            keyboxes[i] = (keyboxes[i] == -1) ? i+3 : i+6;
    }

    // refresh everything if this is him coming back to life
    ST_updateFaceWidget();

    // used by w_arms[] widgets
    st_armson = st_statusbaron && sv_gametype == GM_COOP;

    // used by w_frags widget
    st_fragson = sv_gametype != GM_COOP && st_statusbaron;

    //	[Toke - CTF]
    if (sv_gametype == GM_CTF)
        st_fragscount = TEAMpoints[plyr->userinfo.team]; // denis - todo - scoring for ctf
    else
        st_fragscount = plyr->fragcount;	// [RH] Just use cumulative total

    if (sv_gametype == GM_CTF) {
        switch(CTFdata[it_blueflag].state)
        {
        case flag_home:
            st_flagboxbluon = true;
            break;
        case flag_carried:
            st_flagboxbluon = false;
            break;
        case flag_dropped:
            CTFdata[it_blueflag].sb_tick++;

            if (CTFdata[it_blueflag].sb_tick == 10)
                CTFdata[it_blueflag].sb_tick = 0;

            if (CTFdata[it_blueflag].sb_tick < 8)
                st_flagboxbluon = false;
            else
                st_flagboxbluon = true;
            break;
        default:
            break;
        }
        switch(CTFdata[it_redflag].state)
        {
        case flag_home:
            st_flagboxredon = true;
            break;
        case flag_carried:
            st_flagboxredon = false;
            break;
        case flag_dropped:
            CTFdata[it_redflag].sb_tick++;

            if (CTFdata[it_redflag].sb_tick == 10)
                CTFdata[it_redflag].sb_tick = 0;

            if (CTFdata[it_redflag].sb_tick < 8)
                st_flagboxredon = false;
            else
                st_flagboxredon = true;
            break;
        default:
            break;
        }
    }

    // get rid of chat window if up because of message
    if (!--st_msgcounter)
        st_chat = st_oldchat;

}
Ejemplo n.º 29
0
void G_Ticker (void)
{
	int 		buf;
	gamestate_t	oldgamestate;
	size_t i;

	// Run client tics;
	CL_RunTics ();

	// do player reborns if needed
	if(serverside)
		for (i = 0; i < players.size(); i++)
			if (players[i].ingame() && players[i].playerstate == PST_REBORN)
				G_DoReborn (players[i]);

	// do things to change the game state
	oldgamestate = gamestate;
	while (gameaction != ga_nothing)
	{
		switch (gameaction)
		{
		case ga_loadlevel:
			G_DoLoadLevel (-1);
			break;
		case ga_newgame:
			G_DoNewGame ();
			break;
		case ga_loadgame:
			gameaction = ga_nothing;
			break;
		case ga_savegame:
			gameaction = ga_nothing;
			break;
		case ga_playdemo:
			G_DoPlayDemo ();
			break;
		case ga_completed:
			G_DoCompleted ();
			break;
		case ga_victory:
		    gameaction = ga_nothing;
			break;
		case ga_worlddone:
			G_DoWorldDone ();
			break;
		case ga_screenshot:
			I_ScreenShot(shotfile.c_str());
			gameaction = ga_nothing;
			break;
		case ga_fullconsole:
			C_FullConsole ();
			gameaction = ga_nothing;
			break;
		case ga_nothing:
			break;
		}
		C_AdjustBottom ();
	}

    // get commands
    buf = gametic%BACKUPTICS;
	memcpy (&consoleplayer().cmd, &consoleplayer().netcmds[buf], sizeof(ticcmd_t));

    static int realrate = 0;
    int packet_size;

	if (demoplayback)
		G_ReadDemoTiccmd(); // play all player commands
	if (demorecording)
		G_WriteDemoTiccmd(); // read in all player commands

    if (connected)
    {
       while ((packet_size = NET_GetPacket()) )
       {
		   // denis - don't accept candy from strangers
		   if(!NET_CompareAdr(serveraddr, net_from))
			  break;

           realrate += packet_size;
		   last_received = gametic;
		   noservermsgs = false;

		   CL_ReadPacketHeader();
           CL_ParseCommands();

		   if (gameaction == ga_fullconsole) // Host_EndGame was called
			   return;
       }

       if (!(gametic%TICRATE))
       {
          netin = realrate;
          realrate = 0;
       }

       if (!noservermsgs)
		   CL_SendCmd();  // send console commands to the server

       CL_SaveCmd();      // save console commands

       if (!(gametic%TICRATE))
       {
           netout = outrate;
           outrate = 0;
       }

	   if (gametic - last_received > 65)
		   noservermsgs = true;
	}
	else if (NET_GetPacket() )
	{
		// denis - don't accept candy from strangers
		if((gamestate == GS_DOWNLOAD || gamestate == GS_CONNECTING)
			&& NET_CompareAdr(serveraddr, net_from))
		{
			int type = MSG_ReadLong();

			if(type == CHALLENGE)
			{
				CL_PrepareConnect();
			}
			else if(type == 0)
			{
				if (!CL_Connect())
					memset (&serveraddr, 0, sizeof(serveraddr));

				connecttimeout = 0;
			}
			else
			{
				// we are already connected to this server, quit first
				MSG_WriteMarker(&net_buffer, clc_disconnect);
				NET_SendPacket(net_buffer, serveraddr);
			}
		}
	}

	// check for special buttons
	if(serverside && consoleplayer().ingame())
    {
		player_t &player = consoleplayer();

		if (player.cmd.ucmd.buttons & BT_SPECIAL)
		{
			switch (player.cmd.ucmd.buttons & BT_SPECIALMASK)
			{
			  case BTS_PAUSE:
				paused ^= 1;
				if (paused)
					S_PauseSound ();
				else
					S_ResumeSound ();
				break;

			  case BTS_SAVEGAME:
				if (!savedescription[0])
					strcpy (savedescription, "NET GAME");
				savegameslot =  (player.cmd.ucmd.buttons & BTS_SAVEMASK)>>BTS_SAVESHIFT;
				gameaction = ga_savegame;
				break;
			}
		}
    }
Ejemplo n.º 30
0
void ST_Ticker (void)
{
    st_randomnumber = M_Random();
    ST_updateWidgets();
    st_oldhealth = consoleplayer().health;
}