static void cheat_weapx(const void *arg) { const char *buf = (const char *)arg; int w = *buf - '1'; int pwstr = pw_strength; // WEAPON_FIXME: weap cheat if((w == wp_supershotgun && !enable_ssg) || // killough 2/28/98 ((w == wp_bfg || w == wp_plasma) && GameModeInfo->id == shareware)) return; if(w == wp_fist) // make '1' apply beserker strength toggle cheat_pw(&pwstr); else { if(w >= 0 && w < NUMWEAPONS) { if((plyr->weaponowned[w] = !plyr->weaponowned[w])) doom_printf("Weapon Added"); // Ty 03/27/98 - *not* externalized else { weapontype_t P_SwitchWeapon(player_t *player); doom_printf("Weapon Removed"); // Ty 03/27/98 - *not* externalized if(w == plyr->readyweapon) // maybe switch if weapon removed plyr->pendingweapon = P_SwitchWeapon(plyr); } } } }
static void Z_PrintStats(void) // Print allocation statistics { unsigned long total_memory = free_memory + active_memory + purgable_memory + inactive_memory + virtual_memory; double s = 100.0 / total_memory; doom_printf("%-5u\t%6.01f%%\tstatic\n" "%-5u\t%6.01f%%\tpurgable\n" "%-5u\t%6.01f%%\tfree\n" "%-5u\t%6.01f%%\tfragmentary\n" "%-5u\t%6.01f%%\tvirtual\n" "%-5lu\t\ttotal\n", active_memory, active_memory*s, purgable_memory, purgable_memory*s, free_memory, free_memory*s, inactive_memory, inactive_memory*s, virtual_memory, virtual_memory*s, total_memory ); }
void M_ScreenShot(void) { static int shot; char *lbmname = NULL; int startshot; int success = 0; if (!access_3ds(SCREENSHOT_DIR, 2)) { startshot = shot; // CPhipps - prevent infinite loop do { int size = doom_snprintf(NULL, 0, "%s/doom%02d" SCREENSHOT_EXT, SCREENSHOT_DIR, shot); lbmname = realloc(lbmname, size+1); doom_snprintf(lbmname, size+1, "%s/doom%02d" SCREENSHOT_EXT, SCREENSHOT_DIR, shot); shot++; } while (!access_3ds(lbmname, 0) && (shot != startshot) && (shot < 10000)); if (access_3ds(lbmname, 0)) { S_StartSound(NULL,gamemode==commercial ? sfx_radio : sfx_tink); M_DoScreenShot(lbmname); // cph success = 1; } free(lbmname); if (success) return; } doom_printf ("M_ScreenShot: Couldn't create screenshot"); return; }
static void R_ShowStats(void) { #define KEEPTIMES 10 static int keeptime[KEEPTIMES], showtime; #ifdef INTERNETC static int cnt; #endif int now = I_GetTime(); if (now - showtime > 35) { doom_printf("Frame rate %d fps\nSegs %d, Visplanes %d, Sprites %d", (35*KEEPTIMES)/(now - keeptime[0]), rendered_segs, rendered_visplanes, rendered_vissprites); #ifdef INTERNETC if(cnt==5){ cnt=0; printf("Frame rate %d fps Segs %d, Visplanes %d, Sprites %d\n", (35*KEEPTIMES)/(now - keeptime[0]), rendered_segs, rendered_visplanes, rendered_vissprites); } ++cnt; #endif showtime = now; } memmove(keeptime, keeptime+1, sizeof(keeptime[0]) * (KEEPTIMES-1)); keeptime[KEEPTIMES-1] = now; }
static void cheat_keyxx(const void *arg) { int key = *(const int *)arg; const char *msg = NULL; if(key >= GameModeInfo->numHUDKeys) return; itemeffect_t *fx; if(!(fx = E_ItemEffectForName(GameModeInfo->cardNames[key]))) return; if(!E_GetItemOwnedAmount(plyr, fx)) { E_GiveInventoryItem(plyr, fx); msg = "Key Added"; // Ty 03/27/98 - *not* externalized } else { E_RemoveInventoryItem(plyr, fx, -1); msg = "Key Removed"; } doom_printf("%s", msg); }
void M_ScreenShot(void) { static int shot; char lbmname[PATH_MAX + 1]; int startshot; if (!access(SCREENSHOT_DIR,2)) { startshot = shot; // CPhipps - prevent infinite loop do { sprintf(lbmname,"%s/doom%02d" SCREENSHOT_EXT, SCREENSHOT_DIR, shot++); } while (!access(lbmname,0) && (shot != startshot) && (shot < 10000)); if (access(lbmname,0)) { S_StartSound(NULL,gamemode==commercial ? sfx_radio : sfx_tink); M_DoScreenShot(lbmname); // cph return; } } doom_printf ("M_ScreenShot: Couldn't create screenshot"); return; }
// Pusher cheat // phares 3/10/98 static void cheat_pushers(const void *arg) { C_RunTextCmd("pushers /"); // FIXME: externalize strings doom_printf(allow_pushers ? "pushers enabled" : "pushers disabled"); }
static void cheat_kfa(const void *arg) { cheat_k(arg); cheat_fa(arg); doom_printf(STSTR_KFAADDED); }
static void cheat_fa(const void *arg) { int i; if(!E_PlayerHasBackpack(plyr)) E_GiveBackpack(plyr); itemeffect_t *armor = E_ItemEffectForName(ITEMNAME_IDFAARMOR); if(armor) { plyr->armorpoints = armor->getInt("saveamount", 0); plyr->armorfactor = armor->getInt("savefactor", 1); plyr->armordivisor = armor->getInt("savedivisor", 3); } // WEAPON_FIXME: IDFA cheat // You can't own weapons that aren't in the game - phares 02/27/98 for(i = 0; i < NUMWEAPONS; i++) { if(!(((i == wp_plasma || i == wp_bfg) && GameModeInfo->id == shareware) || (i == wp_supershotgun && !enable_ssg))) plyr->weaponowned[i] = true; } // give full ammo E_GiveAllAmmo(plyr, GAA_MAXAMOUNT); doom_printf("%s", DEH_String("STSTR_FAADDED")); }
// variable friction cheat static void cheat_friction(const void *arg) { C_RunTextCmd("varfriction /"); //sf // FIXME: externalize strings doom_printf(variable_friction ? "Variable Friction enabled" : "Variable Friction disabled" ); }
static void cheat_ammox(const void *arg) { const char *buf = (const char *)arg; int a = *buf - '1'; if(*buf == 'b') { if(!E_PlayerHasBackpack(plyr)) { doom_printf("Backpack Added"); E_GiveBackpack(plyr); } else { doom_printf("Backpack Removed"); E_RemoveBackpack(plyr); } } else if(a >= 0 && a < NUMAMMO) { // haleyjd 10/24/09: altered behavior: // * Add ammo if ammo is not at maxammo. // * Remove ammo otherwise. auto item = E_ItemEffectForName(cheat_AmmoForNum[a]); if(!item) return; int amount = E_GetItemOwnedAmount(plyr, item); int maxamount = E_GetMaxAmountForArtifact(plyr, item); if(amount != maxamount) { E_GiveInventoryItem(plyr, item, maxamount); doom_printf("Ammo Added"); } else { E_RemoveInventoryItem(plyr, item, -1); doom_printf("Ammo Removed"); } } }
static void cheat_mus(const void *arg) { const char *buf = (const char *)arg; //jff 3/20/98 note: this cheat allowed in netgame/demorecord //jff 3/17/98 avoid musnum being negative and crashing if(!ectype::isDigit(buf[0]) || !ectype::isDigit(buf[1])) return; int musnum = GameModeInfo->MusicCheat(buf); if(musnum < 0) doom_printf("%s", DEH_String("STSTR_NOMUS")); // Ty 03/27/98 - externalized else { doom_printf("%s", DEH_String("STSTR_MUS")); // Ty 03/27/98 - externalized S_ChangeMusicNum(musnum, 1); idmusnum = musnum; // jff 3/17/98: remember idmus number for restore } }
// compatibility cheat static void cheat_comp(const void *arg) { int i; // Ty 03/27/98 - externalized doom_printf("%s", DEH_String((compatibility = !compatibility) ? "STSTR_COMPON" : "STSTR_COMPOFF")); for(i = 0; i < COMP_TOTAL; i++) // killough 10/98: reset entire vector comp[i] = compatibility; }
static void CheckQueuedPackets(void) { int i; for (i=0; (unsigned)i<numqueuedpackets; i++) if (doom_ntohl(queuedpacket[i]->tic) <= gametic) switch (queuedpacket[i]->type) { case PKT_QUIT: // Player quit the game { int pn = *(byte*)(queuedpacket[i]+1); playeringame[pn] = false; doom_printf("Player %d left the game\n", pn); } break; case PKT_EXTRA: { int *p = (int*)(queuedpacket[i]+1); size_t len = LONG(*(p+2)); switch (LONG(*p)) { case nm_plcolour: G_ChangedPlayerColour(LONG(*(p+1)), LONG(*(p+3))); break; case nm_savegamename: if (len < SAVEDESCLEN) { memcpy(savedescription, p+3, len); // Force terminating 0 in case savedescription[len] = 0; } break; } } break; default: // Should not be queued break; } { // Requeue remaining packets int newnum = 0; packet_header_t **newqueue = NULL; for (i=0; (unsigned)i<numqueuedpackets; i++) if (doom_ntohl(queuedpacket[i]->tic) > gametic) { newqueue = Z_Realloc(newqueue, ++newnum * sizeof *newqueue, PU_STATIC, NULL); newqueue[newnum-1] = queuedpacket[i]; } else Z_Free(queuedpacket[i]); Z_Free(queuedpacket); numqueuedpackets = newnum; queuedpacket = newqueue; } }
static void Z_DrawStats(void) // Print allocation statistics { if (gamestate != GS_LEVEL) return; if (memory_size > 0) { unsigned long total_memory = free_memory + memory_size + active_memory + purgable_memory; double s = 100.0 / total_memory; doom_printf("%-5i\t%6.01f%%\tstatic\n" "%-5i\t%6.01f%%\tpurgable\n" "%-5i\t%6.01f%%\tfree\n" "%-5li\t\ttotal\n", active_memory, active_memory*s, purgable_memory, purgable_memory*s, (free_memory + memory_size), (free_memory + memory_size)*s, total_memory ); } else { unsigned long total_memory = active_memory + purgable_memory; double s = 100.0 / total_memory; doom_printf("%-5i\t%6.01f%%\tstatic\n" "%-5i\t%6.01f%%\tpurgable\n" "%-5li\t\ttotal\n", active_memory, active_memory*s, purgable_memory, purgable_memory*s, total_memory ); } }
static void R_ShowStats(void) { //e6y #if 1 static unsigned int FPS_SavedTick = 0, FPS_FrameCount = 0; unsigned int tick = SDL_GetTicks(); FPS_FrameCount++; if(tick >= FPS_SavedTick + 1000) { doom_printf((V_GetMode() == VID_MODEGL) ?"Frame rate %d fps\nWalls %d, Flats %d, Sprites %d" :"Frame rate %d fps\nSegs %d, Visplanes %d, Sprites %d", 1000 * FPS_FrameCount / (tick - FPS_SavedTick), rendered_segs, rendered_visplanes, rendered_vissprites); FPS_SavedTick = tick; FPS_FrameCount = 0; } #else #define KEEPTIMES 10 static int keeptime[KEEPTIMES], showtime; int now = I_GetTime(); if (now - showtime > 35) { doom_printf((V_GetMode() == VID_MODEGL) ?"Frame rate %d fps\nWalls %d, Flats %d, Sprites %d" :"Frame rate %d fps\nSegs %d, Visplanes %d, Sprites %d", (35*KEEPTIMES)/(now - keeptime[0]), rendered_segs, rendered_visplanes, rendered_vissprites); showtime = now; } memmove(keeptime, keeptime+1, sizeof(keeptime[0]) * (KEEPTIMES-1)); keeptime[KEEPTIMES-1] = now; #endif //e6y }
static void R_ShowStats(void) { #define KEEPTIMES 10 static int keeptime[KEEPTIMES], showtime; int now = I_GetTime(); if (now - showtime > 35) { #ifdef GL_DOOM doom_printf("Frame rate %d fps\nWalls %d, Flats %d, Sprites %d", #else doom_printf("Frame rate %d fps\nSegs %d, Visplanes %d, Sprites %d", #endif (35*KEEPTIMES)/(now - keeptime[0]), rendered_segs, rendered_visplanes, rendered_vissprites); showtime = now; }
// 'behold?' power-up cheats (modified for infinite duration -- killough) static void cheat_pw(const void *arg) { int pw = *(const int *)arg; if(plyr->powers[pw]) plyr->powers[pw] = pw!=pw_strength && pw!=pw_allmap && pw!=pw_silencer; // killough else { P_GivePower(plyr, pw); if(pw != pw_strength && !comp[comp_infcheat]) plyr->powers[pw] = -1; // infinite duration -- killough } // haleyjd: stop flight if necessary if(pw == pw_flight && !plyr->powers[pw_flight]) P_PlayerStopFlight(plyr); doom_printf("%s", DEH_String("STSTR_BEHOLDX")); // Ty 03/27/98 - externalized }
// 'choppers' invulnerability & chainsaw static void cheat_choppers(const void *arg) { // WEAPON_FIXME: choppers cheat plyr->weaponowned[wp_chainsaw] = true; doom_printf("%s", DEH_String("STSTR_CHOPPERS")); // Ty 03/27/98 - externalized }
static void cheat_k(const void *arg) { // sf: fix multiple 'keys added' messages if(E_GiveAllKeys(plyr)) doom_printf("Keys Added"); }
// 'behold' power-up menu static void cheat_behold(const void *arg) { doom_printf("%s", DEH_String("STSTR_BEHOLD")); // Ty 03/27/98 - externalized }
// // Heretic Kill-All cheat - massacre // static void cheat_htickill(const void *arg) { M_NukeMonsters(); doom_printf("%s", DEH_String("TXT_CHEATMASSACRE")); }
bool M_FindCheats(int key) { static uint64_t sr; static char argbuf[CHEAT_ARGS_MAX+1], *arg; static int init, argsleft, cht; int i, matchedbefore; bool ret; // haleyjd: no cheats in menus, at all. if(menuactive) return false; // If we are expecting arguments to a cheat // (e.g. idclev), put them in the arg buffer if(argsleft) { *arg++ = ectype::toLower(key); // store key in arg buffer if(!--argsleft) // if last key in arg list, cheat[cht].func(argbuf); // process the arg buffer return true; // affirmative response } key = ectype::toLower(key) - 'a'; if(key < 0 || key >= 32) // ignore most non-alpha cheat letters { sr = 0; // clear shift register return false; } if(!init) // initialize aux entries of table { init = 1; for(i = 0; cheat[i].cheat; i++) { uint64_t c=0, m=0; const unsigned char *p; for(p = (const unsigned char *)cheat[i].cheat; *p; p++) { unsigned int ikey = ectype::toLower(*p) - 'a'; // convert to 0-31 if(ikey >= 32) // ignore most non-alpha cheat letters continue; c = (c << 5) + ikey; // shift key into code m = (m << 5) + 31; // shift 1's into mask } cheat[i].code = c; // code for this cheat key cheat[i].mask = m; // mask for this cheat key } } sr = (sr << 5) + key; // shift this key into shift register // haleyjd: Oh Lee, you cad. #if 0 {signed/*long*/volatile/*double *x,*y;*/static/*const*/int/*double*/i; /**/char/*(*)*/*D_DoomExeName/*(int)*/(void)/*?*/;(void/*)^x*/)(( /*sr|1024*/32767/*|8%key*/&sr)-19891||/*isupper(c*/strcasecmp/*)*/ ("b"/*"'%2d!"*/"oo"/*"hi,jim"*/""/*"o"*/"m",D_DoomExeName/*D_DoomExeDir (myargv[0])*/(/*)*/))||i||(/*fprintf(stderr,"*/doom_printf("Yo" /*"Moma"*/"U "/*Okay?*/"mUSt"/*for(you;read;tHis){/_*/" be a "/*MAN! Re-*/ "member"/*That.*/" TO uSe"/*x++*/" t"/*(x%y)+5*/"HiS "/*"Life"*/ "cHe"/*"eze"**/"aT"),i/*+--*/++/*;&^*/));} #endif ret = false; for(matchedbefore = i = 0; cheat[i].cheat; i++) { cheat_s &curcht = cheat[i]; // if match found & allowed if((curcht.gametype == -1 || curcht.gametype == GameModeInfo->type) && (sr & curcht.mask) == curcht.code && !(curcht.when & not_dm && netgame && GameType == gt_dm && !demoplayback) && !(curcht.when & not_coop && netgame && GameType == gt_coop) && !(curcht.when & not_demo && (demorecording || demoplayback)) && !curcht.deh_disabled) { if(curcht.arg < 0) // if additional args are required { cht = i; // remember this cheat code arg = argbuf; // point to start of arg buffer argsleft = -curcht.arg; // number of args expected ret = true; // responder has eaten key } else if(!matchedbefore) // allow only one cheat at a time { matchedbefore = 1; // responder has eaten key ret = true; curcht.func(&(curcht.arg)); // call cheat handler } } } return ret; }
static void cheat_nuke(const void *arg) { extern int enable_nuke; doom_printf((enable_nuke = !enable_nuke) ? "Nukage Enabled" : "Nukage Disabled"); }
// killough 2/16/98: keycard/skullkey cheat functions static void cheat_key(const void *arg) { doom_printf("Red, Yellow, Blue"); // Ty 03/27/98 - *not* externalized }
// killough 2/16/98: generalized ammo cheats static void cheat_ammo(const void *arg) { doom_printf("Ammo 1-4, Backpack"); // Ty 03/27/98 - *not* externalized }
void NetUpdate(void) { static int lastmadetic; if (isExtraDDisplay) return; if (server) { // Receive network packets size_t recvlen; packet_header_t *packet = Z_Malloc(10000, PU_STATIC, NULL); while ((recvlen = I_GetPacket(packet, 10000))) { switch(packet->type) { case PKT_TICS: { uint8_t *p = (void*)(packet+1); int tics = *p++; unsigned long ptic = doom_ntohl(packet->tic); if (ptic > (unsigned)remotetic) { // Missed some packet_set(packet, PKT_RETRANS, remotetic); *(uint8_t*)(packet+1) = consoleplayer; I_SendPacket(packet, sizeof(*packet)+1); } else { if (ptic + tics <= (unsigned)remotetic) break; // Will not improve things remotetic = ptic; while (tics--) { int players = *p++; while (players--) { int n = *p++; RawToTic(&netcmds[n][remotetic%BACKUPTICS], p); p += sizeof(ticcmd_t); } remotetic++; } } } break; case PKT_RETRANS: // Resend request remotesend = doom_ntohl(packet->tic); break; case PKT_DOWN: // Server downed { int j; for (j=0; j<MAXPLAYERS; j++) if (j != consoleplayer) playeringame[j] = FALSE; server = FALSE; doom_printf("Server is down\nAll other players are no longer in the game\n"); } break; case PKT_EXTRA: // Misc stuff case PKT_QUIT: // Player quit // Queue packet to be processed when its tic time is reached queuedpacket = Z_Realloc(queuedpacket, ++numqueuedpackets * sizeof *queuedpacket, PU_STATIC, NULL); queuedpacket[numqueuedpackets-1] = Z_Malloc(recvlen, PU_STATIC, NULL); memcpy(queuedpacket[numqueuedpackets-1], packet, recvlen); break; case PKT_BACKOFF: /* cph 2003-09-18 - * The server sends this when we have got ahead of the other clients. We should * stall the input side on this client, to allow other clients to catch up. */ lastmadetic++; break; default: // Other packet, unrecognised or redundant break; } } Z_Free(packet); } { // Build new ticcmds int newtics = I_GetTime() - lastmadetic; newtics = (newtics > 0 ? newtics : 0); lastmadetic += newtics; if (ffmap) newtics++; while (newtics--) { I_StartTic(); if (maketic - gametic > BACKUPTICS/2) break; G_BuildTiccmd(&localcmds[maketic%BACKUPTICS]); maketic++; } if (server && maketic > remotesend) { // Send the tics to the server int sendtics; remotesend -= xtratics; if (remotesend < 0) remotesend = 0; sendtics = maketic - remotesend; { size_t pkt_size = sizeof(packet_header_t) + 2 + sendtics * sizeof(ticcmd_t); packet_header_t *packet = Z_Malloc(pkt_size, PU_STATIC, NULL); packet_set(packet, PKT_TICC, maketic - sendtics); *(uint8_t*)(packet+1) = sendtics; *(((uint8_t*)(packet+1))+1) = consoleplayer; { void *tic = ((uint8_t*)(packet+1)) +2; while (sendtics--) { TicToRaw(tic, &localcmds[remotesend++%BACKUPTICS]); tic = (uint8_t *)tic + sizeof(ticcmd_t); } } I_SendPacket(packet, pkt_size); Z_Free(packet); } } } }
// killough 2/16/98: generalized weapon cheats static void cheat_weap(const void *arg) { // Ty 03/27/98 - *not* externalized doom_printf(enable_ssg ? // killough 2/28/98 "Weapon number 1-9" : "Weapon number 1-8" ); }
static void cheat_keyx(const void *arg) { doom_printf("Card, Skull"); // Ty 03/27/98 - *not* externalized }
static void cheat_printstats(const void *arg) // killough 8/23/98 { if(!(printstats = !printstats)) doom_printf("Memory stats off"); }