void TryRunTics(void) { int i; int lowtic; int entertic; static int oldentertics; int realtics; int availabletics; int counts; // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; // get available tics NetUpdate(); lowtic = GetLowTic(); availabletics = lowtic - gametic / ticdup; // decide how many tics to run if (net_cl_new_sync) { counts = availabletics; } else { // decide how many tics to run if (realtics < availabletics - 1) counts = realtics + 1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; if (counts < 1) counts = 1; frameon++; if (!demoplayback) { int keyplayer = -1; // ideally maketic should be 1 - 3 tics above lowtic // if we are consistantly slower, speed up time for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { keyplayer = i; break; } } if (keyplayer < 0) { // If there are no players, we can never advance anyway return; } if (consoleplayer == keyplayer) { // the key player does not adapt } else { if (maketic <= nettics[keyplayer]) { lasttime--; } frameskip[frameon & 3] = (oldnettics > nettics[keyplayer]); oldnettics = maketic; if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) { skiptics = 1; } } } } if (counts < 1) counts = 1; // wait for new tics if needed while (!PlayersInGame() || lowtic < gametic / ticdup + counts) { NetUpdate(); lowtic = GetLowTic(); // Don't stay in this loop forever. The menu is still running, // so return to update the screen if (I_GetTime() / ticdup - entertic > 0) { return; } I_Sleep(1); } // run the count * ticdup dics while (counts--) { for (i = 0; i < ticdup; i++) { // check that there are players in the game. if not, we cannot // run a tic. if (!PlayersInGame()) { return; } if (advancedemo) D_DoAdvanceDemo(); G_Ticker(); gametic++; // modify command for duplicated tics if (i != ticdup - 1) { ticcmd_t *cmd; int buf; int j; buf = (gametic / ticdup) % BACKUPTICS; for (j = 0; j < MAXPLAYERS; j++) { cmd = &netcmds[j][buf]; if (cmd->buttons & BT_SPECIAL) cmd->buttons = 0; } } } NetUpdate(); // check for new console commands } }
void TryRunTics (void) { int i; int lowtic; int entertic; static int oldentertics; int realtics; int availabletics; int counts; // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; // in singletics mode, run a single tic every time this function // is called. if (singletics) { BuildNewTic(); } else { NetUpdate (); } lowtic = GetLowTic(); availabletics = lowtic - gametic/ticdup; // decide how many tics to run if (new_sync) { counts = availabletics; } else { // decide how many tics to run if (realtics < availabletics-1) counts = realtics+1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; if (counts < 1) counts = 1; if (net_client_connected) { OldNetSync(); } } if (counts < 1) counts = 1; // wait for new tics if needed while (!PlayersInGame() || lowtic < gametic/ticdup + counts) { NetUpdate (); lowtic = GetLowTic(); if (lowtic < gametic/ticdup) I_Error ("TryRunTics: lowtic < gametic"); // Still no tics to run? Sleep until some are available. if (lowtic < gametic/ticdup + counts) { // If we're in a netgame, we might spin forever waiting for // new network data to be received. So don't stay in here // forever - give the menu a chance to work. if (I_GetTime() / ticdup - entertic >= MAX_NETGAME_STALL_TICS) { return; } I_Sleep(1); } } // run the count * ticdup dics while (counts--) { ticcmd_set_t *set; if (!PlayersInGame()) { return; } set = &ticdata[(gametic / ticdup) % BACKUPTICS]; if (!net_client_connected) { SinglePlayerClear(set); } for (i=0 ; i<ticdup ; i++) { if (gametic/ticdup > lowtic) I_Error ("gametic>lowtic"); memcpy(local_playeringame, set->ingame, sizeof(local_playeringame)); loop_interface->RunTic(set->cmds, set->ingame); gametic++; // modify command for duplicated tics TicdupSquash(set); } NetUpdate (); // check for new console commands } }
void TryRunTics (void) { int i; int lowtic; int entertic; static int oldentertics; int realtics; int availabletics; int counts; // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; // in singletics mode, run a single tic every time this function // is called. if (singletics) { BuildNewTic(); } else { NetUpdate (); } lowtic = GetLowTic(); availabletics = lowtic - gametic/ticdup; // decide how many tics to run if (new_sync) { counts = availabletics; } else { // decide how many tics to run if (realtics < availabletics-1) counts = realtics+1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; if (counts < 1) counts = 1; if (net_client_connected) { OldNetSync(); } } if (counts < 1) counts = 1; // wait for new tics if needed while (!PlayersInGame() || lowtic < gametic/ticdup + counts) { NetUpdate (); lowtic = GetLowTic(); if (lowtic < gametic/ticdup) I_Error ("TryRunTics: lowtic < gametic"); // Don't stay in this loop forever. The menu is still running, // so return to update the screen if (I_GetTime() / ticdup - entertic > 0) { return; } I_Sleep(1); } // run the count * ticdup dics while (counts--) { ticcmd_set_t *set; if (!PlayersInGame()) { return; } set = &ticdata[(gametic / ticdup) % BACKUPTICS]; if (!net_client_connected) { SinglePlayerClear(set); } for (i=0 ; i<ticdup ; i++) { if (gametic/ticdup > lowtic) I_Error ("gametic>lowtic"); memcpy(local_playeringame, set->ingame, sizeof(local_playeringame)); loop_interface->RunTic(set->cmds, set->ingame); gametic++; // modify command for duplicated tics TicdupSquash(set); } NetUpdate (); // check for new console commands } }
/* ============== BotAISetupClient ============== */ int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart) { bot_state_t *bs; if (!botstates[client]) botstates[client] = (bot_state_t *) malloc(sizeof(bot_state_t)); //G_Alloc(sizeof(bot_state_t)); //rww - G_Alloc bad! malloc good. memset(botstates[client], 0, sizeof(bot_state_t)); bs = botstates[client]; if (bs && bs->inuse) { return qfalse; } memcpy(&bs->settings, settings, sizeof(bot_settings_t)); bs->client = client; //need to know the client number before doing personality stuff //initialize weapon weight defaults.. bs->botWeaponWeights[WP_NONE] = 0; bs->botWeaponWeights[WP_STUN_BATON] = 1; bs->botWeaponWeights[WP_SABER] = 0; bs->botWeaponWeights[WP_BRYAR_PISTOL] = 11; bs->botWeaponWeights[WP_BLASTER] = 12; bs->botWeaponWeights[WP_DISRUPTOR] = 13; bs->botWeaponWeights[WP_BOWCASTER] = 14; bs->botWeaponWeights[WP_REPEATER] = 15; bs->botWeaponWeights[WP_DEMP2] = 16; bs->botWeaponWeights[WP_FLECHETTE] = 17; bs->botWeaponWeights[WP_ROCKET_LAUNCHER] = 18; bs->botWeaponWeights[WP_THERMAL] = 14; bs->botWeaponWeights[WP_TRIP_MINE] = 0; bs->botWeaponWeights[WP_DET_PACK] = 0; bs->botWeaponWeights[WP_MELEE] = 1; BotUtilizePersonality(bs); if (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL) { bs->botWeaponWeights[WP_SABER] = 13; } #ifndef __MMO__ //allocate a goal state bs->gs = trap_BotAllocGoalState(client); //allocate a weapon state bs->ws = trap_BotAllocWeaponState(); #endif //__MMO__ bs->inuse = qtrue; bs->entitynum = client; bs->setupcount = 4; bs->entergame_time = FloatTime(); #ifndef __MMO__ bs->ms = trap_BotAllocMoveState(); #endif //__MMO__ numbots++; //NOTE: reschedule the bot thinking BotScheduleBotThink(); if (PlayersInGame()) { //don't talk to yourself BotDoChat(bs, "GeneralGreetings", 0); } return qtrue; }