diff --git a/source/sw/src/console.cpp b/source/sw/src/console.cpp index 0689f0140..ce8491786 100644 --- a/source/sw/src/console.cpp +++ b/source/sw/src/console.cpp @@ -74,10 +74,6 @@ uint8_t CON_CommandCmp(const char *str1, const char *str2, int len); void CheatInput(void); // Modify actor routines -void CON_ModXrepeat(void); -void CON_ModYrepeat(void); -void CON_ModTranslucent(void); -void CON_GetHelp(void); void CON_Sound(void); void CON_Reverb(void); void CON_Heap(void); @@ -91,13 +87,11 @@ void CON_Quit(void); void CON_LoadSetup(void); void CON_DamageData(void); void CON_WinPachinko(void); -void CON_Tweak(void); void CON_Bunny(void); void CON_CheckHeap(void); void CON_DumpHeap(void); void CON_ShowMirror(void); void CON_MultiNameChange(void); -void CON_DumpSoundList(void); // STRUCTURES //////////////////////////////////////////////////////////////////////////////// @@ -128,24 +122,8 @@ CON_COMMAND pre_commands[] = {"george", CheatInput}, {"blackburn", CheatInput}, {"reverb", CON_Reverb}, - {"mem", CON_Heap}, - {"cache", CON_Cache}, - {"xrepeat", CON_ModXrepeat}, - {"yrepeat", CON_ModYrepeat}, - {"translucent", CON_ModTranslucent}, - {"spriteinfo", CON_SpriteInfo}, - {"kill", CON_KillSprite}, - {"showsprite", CON_SpriteDetail}, - {"showuser", CON_UserDetail}, - {"damage", CON_DamageData}, - {"tweak", CON_Tweak}, - {"checkheap", CON_CheckHeap}, - {"dumpheap", CON_DumpHeap}, {"showmirror", CON_ShowMirror}, {"clear", CON_ClearConsole}, - {"dumpsounds", CON_DumpSoundList}, - {"help", CON_GetHelp}, -//{"quit", CON_Quit}, #endif {"swgod", CheatInput}, {"swchan", CheatInput}, @@ -171,11 +149,7 @@ CON_COMMAND pre_commands[] = {"swgun#", CheatInput}, {"swquit", CheatInput}, {"swexit", CheatInput}, - {"sound", CON_SoundTest}, - {"winpachinko", CON_WinPachinko}, - {"config", CON_LoadSetup}, {"swtrix", CON_Bunny}, - {"swname", CON_MultiNameChange}, {NULL, NULL} }; @@ -396,213 +370,6 @@ void CON_ClearConsole(void) strcpy(con_quote[i],"\0"); } -///////////////////////////////////////////////////////////////////////////////////////////// -// The user console programming function library //////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// - -SWBOOL CheckValidSprite(short SpriteNum) -{ - if (SpriteNum < 0 || SpriteNum > 6144) - { - OSD_Printf("ERROR: Sprite %d is out of range.",SpriteNum); - return FALSE; - } - return TRUE; -} - -// Get help on a console command -void CON_GetHelp(void) -{ - char base[80], command[80]; - short i; - - - if (sscanf(MessageInputString,"%s %s",base,command) < 2) - { - OSD_Printf("Usage: help [keyword]"); - return; - } - - Bstrlwr(command); // Make sure operator is all lower case - - if (!strcmp(command, "xrepeat")) - { - OSD_Printf("Usage: xrepeat [repeat value 0-255],"); - OSD_Printf(" [User ID (-1 for all ID's)], [SpriteNum (-1 for all of type ID)]"); - return; - } - else if (!strcmp(command, "yrepeat")) - { - OSD_Printf("Usage: yrepeat [repeat value 0-255],"); - OSD_Printf(" [User ID (-1 for all ID's)], [SpriteNum (-1 for all of type ID)]"); - return; - } - else if (!strcmp(command, "translucent")) - { - OSD_Printf("Usage: translucent [OFF/ON 0-1],"); - OSD_Printf(" [User ID (-1 for all ID's)], [SpriteNum (-1 for all of type ID)]"); - return; - } - else - { - OSD_Printf("No help was located on that subject."); - } -} - -// Modify sprites xrepeat value -void CON_ModXrepeat(void) -{ - char base[80]; - int16_t op1=64,op2=-1,op3=-1; - short i; - - - if (sscanf(MessageInputString,"%s %hd %hd %hd",base,&op1,&op2,&op3) < 4) - { - strcpy(MessageInputString,"help xrepeat"); - CON_GetHelp(); - return; - } - - if (op3 == -1) - { - for (i=0; ixrepeat = op1; - else - { - if (u->ID == op2) - sp->xrepeat = op1; - } - } - if (op2 == -1) - OSD_Printf("Xrepeat set to %d for all u->ID's for all sprites.",op1); - else - OSD_Printf("Xrepeat set to %d for u->ID = %d for all sprites.",op1,op2); - } - else - { - // Do it only for one sprite - SPRITEp sp = &sprite[op3]; - USERp u = User[op3]; - - if (!CheckValidSprite(op3)) return; - - sp->xrepeat = op1; - OSD_Printf("Xrepeat set to %d for sprite %d.",op1,op3); - } -} - -// Modify sprites yrepeat value -void CON_ModYrepeat(void) -{ - char base[80]; - int16_t op1=64,op2=-1,op3=-1; - short i; - - - if (sscanf(MessageInputString,"%s %hd %hd %hd",base,&op1,&op2,&op3) < 4) - { - strcpy(MessageInputString,"help yrepeat"); - CON_GetHelp(); - return; - } - - - if (op3 == -1) - { - for (i=0; iyrepeat = op1; - else - { - if (u->ID == op2) - sp->yrepeat = op1; - } - } - if (op2 == -1) - OSD_Printf("Yrepeat set to %d for all u->ID's for all sprites.",op1); - else - OSD_Printf("Yrepeat set to %d for u->ID = %d for all sprites.",op1,op2); - } - else - { - // Do it only for one sprite - SPRITEp sp = &sprite[op3]; - USERp u = User[op3]; - - if (!CheckValidSprite(op3)) return; - - sp->yrepeat = op1; - OSD_Printf("Yrepeat set to %d for sprite %d.",op1,op3); - } -} - -void CON_ModTranslucent(void) -{ - char base[80]; - int16_t op1=0; - SPRITEp sp; - USERp u; - - // Format: translucent [SpriteNum] - if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) - { - strcpy(MessageInputString,"help translucent"); - CON_GetHelp(); - return; - } - - if (!CheckValidSprite(op1)) return; - - sp = &sprite[op1]; - u = User[op1]; - - if (TEST(sp->cstat,CSTAT_SPRITE_TRANSLUCENT)) - { - RESET(sp->cstat,CSTAT_SPRITE_TRANSLUCENT); - OSD_Printf("Translucence RESET for sprite %d.",op1); - } - else - { - SET(sp->cstat,CSTAT_SPRITE_TRANSLUCENT); - OSD_Printf("Translucence SET for sprite %d.",op1); - } -} - -void CON_SoundTest(void) -{ - int handle; - int zero=0; - char base[80]; - int16_t op1=0; - - // Format: sound [number] - if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) - { - strcpy(MessageInputString,"help sound"); - CON_GetHelp(); - return; - } - - if (op1 < 0 || op1 >= DIGI_MAX) - { - OSD_Printf("Sound number out of range."); - return; - } - - handle = PlaySound(op1,&zero,&zero,&zero,v3df_none); -} - - void CON_Reverb(void) { char base[80]; @@ -613,7 +380,6 @@ void CON_Reverb(void) if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) { strcpy(MessageInputString,"help reverb"); - CON_GetHelp(); return; } @@ -621,641 +387,6 @@ void CON_Reverb(void) COVER_SetReverb(op1); pp->Reverb = op1; } - -void CON_Heap(void) -{ - /* - int totalmemory=0; - extern int TotalMemory, ActualHeap; - int i; - void *testheap; - - totalmemory = Z_AvailHeap(); - OSD_Printf("Total heap at game startup = %d", TotalMemory); - OSD_Printf("ActualHeap reserved for non-cache use = %d", ActualHeap); - OSD_Printf("Total unallocated blocks in bytes minus reserved heap = %d", totalmemory); - OSD_Printf("NOTE: Allocation exceeding ActualHeap will result in out of memory"); - // Find remaining heap space unused - i = ActualHeap; - while(i>0) - { - testheap = AllocMem(i); - if(!testheap) - i-=1024L; // Decrease in 1k increments - else - { - OSD_Printf("Heap test result (+ or - 1k):"); - OSD_Printf("============================="); - OSD_Printf("Unallocated heap space remaining = %d",i); - OSD_Printf("Unallocated heap space used = %d",ActualHeap - i); - FreeMem(testheap); - i=0; // Beam us out of here Scotty! - } - } - - if(ActualHeap < 50000L) - { - OSD_Printf("ALERT: Memory is critically low!"); - } - */ -} - -int TileRangeMem(int start) -{ - int i; - int total=0; - - switch (start) - { - case 4096: // Evil Ninja - for (i=4096; i<=4239; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 800: // Hornet - for (i=800; i<=811; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 817: - for (i=817; i<=819; i++) // Bouncing Betty - total += tilesiz[i].x*tilesiz[i].y; - break; - case 820: // Skull - for (i=820; i<=854; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 960: - for (i=960; i<=1016; i++) // Serpent God - total += tilesiz[i].x*tilesiz[i].y; - for (i=1300; i<=1314; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 1024: - for (i=1024; i<=1175; i++) // LoWang - total += tilesiz[i].x*tilesiz[i].y; - break; - case 1320: - for (i=1320; i<=1396; i++) // Skeletor Priest - total += tilesiz[i].x*tilesiz[i].y; - break; - case 1400: - for (i=1400; i<=1440; i++) // Coolie - total += tilesiz[i].x*tilesiz[i].y; - for (i=4260; i<=4266; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 1441: - for (i=1441; i<=1450; i++) // Coolie Ghost - total += tilesiz[i].x*tilesiz[i].y; - for (i=4267; i<=4312; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 1469: - for (i=1469; i<=1497; i++) // Guardian - total += tilesiz[i].x*tilesiz[i].y; - for (i=1504; i<=1518; i++) - total += tilesiz[i].x*tilesiz[i].y; - break; - case 1580: - for (i=1580; i<=1644; i++) // Little Ripper - total += tilesiz[i].x*tilesiz[i].y; - break; - case 4320: - for (i=4320; i<=4427; i++) // Big Ripper - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2540: - for (i=2540; i<=2546; i++) // Trashcan - total += tilesiz[i].x*tilesiz[i].y; - break; - case 4430: - for (i=4430; i<=4479; i++) // Fish - total += tilesiz[i].x*tilesiz[i].y; - break; - case 4490: - for (i=4490; i<=4544; i++) // Sumo - total += tilesiz[i].x*tilesiz[i].y; - break; - case 5023: - for (i=5023; i<=5026; i++) // Toilet Girl - total += tilesiz[i].x*tilesiz[i].y; - break; - case 5032: - for (i=5032; i<=5035; i++) // Wash Girl - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2000: - for (i=2000; i<=2002; i++) // Chop Stick Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2004: - for (i=2004; i<=2009; i++) // Uzi Panel - total += tilesiz[i].x*tilesiz[i].y; - for (i=2040; i<=2043; i++) // Uzi Overlays - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2010: - for (i=2010; i<=2019; i++) // Rail Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2130: - for (i=2130; i<=2137; i++) // Shuriken Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2050: - for (i=2050; i<=2053; i++) // Heart Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2054: - for (i=2054; i<=2057; i++) // HotHead Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2070: - for (i=2070; i<=2077; i++) // Rocket Launcher Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2080: - for (i=2080; i<=2083; i++) // Sword Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 4090: - for (i=4090; i<=4093; i++) // Bloody Sword Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2121: - for (i=2121; i<=2126; i++) // 40MM Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2211: - for (i=2211; i<=2216; i++) // Shotgun Panel - total += tilesiz[i].x*tilesiz[i].y; - for (i=2225; i<=2227; i++) // Shotgun Quad-Mode Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - case 2220: - for (i=2220; i<=2224; i++) // Sticky Bomb Panel - total += tilesiz[i].x*tilesiz[i].y; - break; - } - - return total; -} - -void CON_Cache(void) -{ - char incache[MAXTILES]{}; - int i,j,tottiles,totsprites,totactors; - - // Calculate all level tiles, non-actor stuff - for (i=0; i= 0) - incache[wall[i].overpicnum] = 1; - } - - tottiles = 0; - for (i=0; i 0) - tottiles += tilesiz[i].x*tilesiz[i].y; - - ////////////////////////////////////////////// - - memset(incache, 0, sizeof(incache)); - - // Sprites on the stat list get counted as cached, others don't - for (i=0; i 0) - { - switch (i) - { - case 4096: - totactors+=TileRangeMem(4096); - incache[4096]=0; - break; - case 800: - totactors+=TileRangeMem(800); - incache[800]=0; - break; - case 817: - totactors+=TileRangeMem(817); - incache[817]=0; - break; - case 820: - totactors+=TileRangeMem(820); - incache[820]=0; - break; - case 960: - totactors+=TileRangeMem(960); - incache[960]=0; - break; - //case 1024: // Lo Wang is calculated later - // totactors+=TileRangeMem(1024); - // incache[1024]=0; - //break; - case 1320: - totactors+=TileRangeMem(1320); - incache[1320]=0; - break; - case 1400: - totactors+=TileRangeMem(1400); - incache[1400]=0; - break; - case 1441: - totactors+=TileRangeMem(1441); - incache[1441]=0; - break; - case 1469: - totactors+=TileRangeMem(1469); - incache[1469]=0; - break; - case 1580: - totactors+=TileRangeMem(1580); - incache[1580]=0; - break; - case 4320: - totactors+=TileRangeMem(4320); - incache[4320]=0; - break; - case 2540: - totactors+=TileRangeMem(2540); - incache[2540]=0; - break; - case 4430: - totactors+=TileRangeMem(4430); - incache[4430]=0; - break; - case 4490: - totactors+=TileRangeMem(4490); - incache[4490]=0; - break; - case 5023: - totactors+=TileRangeMem(5023); - incache[5023]=0; - break; - case 5032: - totactors+=TileRangeMem(5032); - incache[5032]=0; - break; - case 2000: - totactors+=TileRangeMem(2000); - incache[2000]=0; - break; - case 2004: - totactors+=TileRangeMem(2004); - incache[2004]=0; - break; - case 2010: - totactors+=TileRangeMem(2010); - incache[2010]=0; - break; - case 2130: - totactors+=TileRangeMem(2130); - incache[2130]=0; - break; - case 2050: - totactors+=TileRangeMem(2050); - incache[2050]=0; - break; - case 2054: - totactors+=TileRangeMem(2054); - incache[2054]=0; - break; - case 2070: - totactors+=TileRangeMem(2070); - incache[2070]=0; - break; - case 2080: - totactors+=TileRangeMem(2080); - incache[2080]=0; - break; - case 4090: - totactors+=TileRangeMem(4090); - incache[4090]=0; - break; - case 2121: - totactors+=TileRangeMem(2121); - incache[2121]=0; - break; - case 2211: - totactors+=TileRangeMem(2211); - incache[2211]=0; - break; - case 2220: - totactors+=TileRangeMem(2220); - incache[2220]=0; - break; - - default: totsprites += tilesiz[i].x*tilesiz[i].y; - } - } - } - - OSD_Printf("/////////////////////////////////////////////"); - OSD_Printf("Current Memory Consumption:"); - OSD_Printf("Total Tiles = %d",tottiles); - OSD_Printf("Total Sprites = %d",totsprites); - OSD_Printf("Total Actors = %d",totactors); - OSD_Printf("Total Memory = %d",(tottiles+totsprites+totactors)); - OSD_Printf("Total with LoWang = %d",(tottiles+totsprites+totactors+TileRangeMem(1024))); - OSD_Printf("/////////////////////////////////////////////"); - -} - -void CON_SpriteInfo(void) -{ - SpriteInfo++; - if (SpriteInfo > 2) SpriteInfo = 0; - - if (SpriteInfo == 0) - OSD_Printf("Sprite information is OFF."); - else if (SpriteInfo == 1) - OSD_Printf("Sprite information is ON (Brief Mode)."); - else - OSD_Printf("Sprite information is ON (Verbose Mode)."); -} - -void CON_KillSprite(void) -{ - char base[80]; - int16_t op1=0; - SPRITEp sp; - short i; - USERp u; - - // Format: kill [SpriteNum] - if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) - { - strcpy(MessageInputString,"help kill"); - CON_GetHelp(); - return; - } - - if (op1 == -1) - { - for (i=0; iPlayerP) - SetSuicide(i); - } - OSD_Printf("Killed all sprites except Players."); - } - else - { - if (!CheckValidSprite(op1)) return; - - SetSuicide(op1); - OSD_Printf("Killed sprite %d.",op1); - } - -} - -void CON_SpriteDetail(void) -{ - char base[80]; - int16_t op1=0; - short i; - - // Format: showsprite [SpriteNum] - if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) - { - strcpy(MessageInputString,"help showsprite"); - CON_GetHelp(); - return; - } - - if (!CheckValidSprite(op1)) return; - auto const sp = (uspritetype const *)&sprite[op1]; - - OSD_Printf("x = %d, y = %d, z = %d",sp->x,sp->y,sp->z); - OSD_Printf("cstat = %d, picnum = %d",sp->cstat,sp->picnum); - OSD_Printf("shade = %d, pal = %d, clipdist = %d",sp->shade,sp->pal,sp->clipdist); - OSD_Printf("xrepeat = %d, yrepeat = %d",sp->xrepeat, sp->yrepeat); - OSD_Printf("xoffset = %d, yoffset = %d",sp->xoffset, sp->yoffset); - OSD_Printf("sectnum = %d, statnum = %d",sp->sectnum, sp->statnum); - OSD_Printf("ang = %d, owner = %d",sp->ang,sp->owner); - OSD_Printf("xvel = %d, yvel = %d, zvel = %d",sp->xvel,sp->yvel,sp->zvel); - OSD_Printf("lotag = %d, hitag = %d, extra = %d",sp->lotag,sp->hitag,sp->extra); -} - -void CON_UserDetail(void) -{ - char base[80]; - int16_t op1=0; - SPRITEp sp; - short i; - USERp u; - - // Format: showuser [SpriteNum] - if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) - { - strcpy(MessageInputString,"help showsprite"); - CON_GetHelp(); - return; - } - - if (!CheckValidSprite(op1)) return; - sp = &sprite[op1]; - u = User[op1]; - - if (!u) return; - - OSD_Printf("State = %p, Rot = %p",u->State,u->Rot); - OSD_Printf("StateStart = %p, StateEnd = %p",u->StateStart,u->StateEnd); - OSD_Printf("ActorActionFunc = %p",u->ActorActionFunc); - OSD_Printf("ActorActionSet = %p",u->ActorActionSet); - OSD_Printf("Personality = %p",u->Personality); - OSD_Printf("Attrib = %p",u->Attrib); - OSD_Printf("Flags = %d, Flags2 = %d, Tics = %d",u->Flags,u->Flags2,u->Tics); - OSD_Printf("RotNum = %d, ID = %d",u->RotNum,u->ID); - OSD_Printf("Health = %d, MaxHealth = %d",u->Health,u->MaxHealth); - OSD_Printf("LastDamage = %d, PainThreshold = %d",u->LastDamage,u->PainThreshold); - OSD_Printf("jump_speed = %d, jump_grav = %d",u->jump_speed,u->jump_grav); - OSD_Printf("xchange = %d, ychange = %d, zchange = %d",u->xchange,u->ychange,u->zchange); - OSD_Printf("ret = %d, WaitTics = %d, spal = %d",u->ret,u->WaitTics,u->spal); -} - -void CON_Quit(void) -{ - if (CommPlayers >= 2) - MultiPlayQuitFlag = TRUE; - else - QuitFlag = TRUE; -} - -void CON_MultiNameChange(void) -{ - char base[16],command[16]; - - // Format: swname [name] - if (sscanf(MessageInputString,"%6s %12s",base,command) < 2) - return; - - SendMulitNameChange(command); -} - -void CON_LoadSetup(void) -{ - OSD_Printf("JonoF: Maybe later"); -} - -const char *damagename[] = -{ - "WPN_STAR","WPN_UZI", - "WPN_SHOTGUN","WPN_MICRO", - "WPN_GRENADE","WPN_MINE", - "WPN_RAIL","WPN_HEART", - "WPN_HOTHEAD","WPN_NAPALM" - "WPN_RING","WPN_ROCKET", - "WPN_SWORD","WPN_FIST", - "DMG_NAPALM","DMG_MIRV_METEOR", - "DMG_SERP_METEOR","DMG_ELECTRO_SHARD", - "DMG_SECTOR_EXP","DMG_BOLT_EXP", - "DMG_TANK_SHELL_EXP","DMG_FIREBALL_EXP", - "DMG_NAPALM_EXP","DMG_SKULL_EXP", - "DMG_BASIC_EXP","DMG_GRENADE_EXP", - "DMG_MINE_EXP","DMG_MINE_SHRAP", - "DMG_MICRO_EXP","DMG_NUCLEAR_EXP", - "DMG_RADIATION_CLOUD","DMG_FLASHBOMB", - "DMG_FIREBALL_FLAMES","DMG_RIPPER_SLASH", - "DMG_SKEL_SLASH","DMG_COOLG_BASH", - "DMG_COOLG_FIRE","DMG_GORO_CHOP", - "DMG_GORO_FIREBALL","DMG_SERP_SLASH", - "DMG_LAVA_BOULDER","DMG_LAVA_SHARD", - "DMG_HORNET_STING","DMG_EEL_ELECTRO", - "DMG_SPEAR_TRAP","DMG_VOMIT", - "DMG_BLADE" -}; - -void CON_DamageData(void) -{ - - char base[80],field[80]; - int16_t op1=0; - unsigned int op2, i; - - // Format: damage [field] [item] [value] - if (sscanf(MessageInputString,"%s %s %hd %u",base,field,&op1,&op2) < 3) - { - strcpy(MessageInputString,"help damage"); - CON_GetHelp(); - return; - } - - if (op1 < -1 || op1 > 46) - { - OSD_Printf("Damage Data index is out of range."); - return; - } - - if (!strcmp(field,"damage_lo")) - { - DamageData[op1].damage_lo = op2; - OSD_Printf("DamageData[%s].damage_lo = %d",damagename[op1],op2); - } - else if (!strcmp(field,"damage_hi")) - { - DamageData[op1].damage_hi = op2; - OSD_Printf("DamageData[%s].damage_hi = %d",damagename[op1],op2); - } - else if (!strcmp(field,"radius")) - { - DamageData[op1].radius = op2; - OSD_Printf("DamageData[%s].radius = %d",damagename[op1],op2); - } - else if (!strcmp(field,"max_ammo")) - { - DamageData[op1].max_ammo = op2; - OSD_Printf("DamageData[%s].max_ammo = %d",damagename[op1],op2); - } - else if (!strcmp(field,"min_ammo")) - { - DamageData[op1].min_ammo = op2; - OSD_Printf("DamageData[%s].min_ammo = %d",damagename[op1],op2); - } - if (!strcmp(field,"show")) - { - if (op1 == -1) - { - for (i=op2; i<=op2+10; i+=2) - { - if (i<47) - OSD_Printf("[%d] = %s [%d] = %s",i,damagename[i],i+1,damagename[i+1]); - } - } - else - { - OSD_Printf(" "); - OSD_Printf("Item = %s:",damagename[op1]); - OSD_Printf("damage_lo = %d, damag_hi = %d",DamageData[op1].damage_lo,DamageData[op1].damage_hi); - OSD_Printf("radius = %u",DamageData[op1].radius); - OSD_Printf("min_ammo = %d, max_ammo = %d",DamageData[op1].min_ammo,DamageData[op1].max_ammo); - OSD_Printf(" "); - } - } -} - -void CON_WinPachinko(void) -{ - extern SWBOOL Pachinko_Win_Cheat; - PLAYERp pp = Player + myconnectindex; - extern void CheckSndData(char *file, int line); - - if (CommEnabled) - return; - - Pachinko_Win_Cheat = !Pachinko_Win_Cheat; - - //CheckSndData( __FILE__, __LINE__ ); - - if (Pachinko_Win_Cheat) - PutStringInfo(pp,"Pachinko Win Cheat Enabled"); - else - PutStringInfo(pp,"Pachinko Win Cheat Disabled"); -} - -void CON_Tweak(void) -{ - char base[80], command[80]; - int op1=0; - - // Format: tweak [weapon] [number] - if (sscanf(MessageInputString,"%s %s %d",base,command,&op1) < 3) - { - strcpy(MessageInputString,"help tweak"); - CON_GetHelp(); - return; - } - - Bstrlwr(command); // Make sure operator is all lower case - if (!strcmp(command,"adjust")) - { - extern short ADJUST; - ADJUST = op1; - OSD_Printf("Zvelocity ADJUST set to %d.",op1); - } - else if (!strcmp(command,"adjustv")) - { - extern int ADJUSTV; - ADJUSTV = op1; - OSD_Printf("Zvelocity ADJUSTV set to %d.",op1); - } -} - void CON_Bunny(void) { PLAYERp pp = Player + myconnectindex; @@ -1270,70 +401,6 @@ void CON_Bunny(void) PutStringInfo(pp,"Bunny rockets disabled!"); } -void CON_CheckHeap(void) -{ - /* - switch( _heapchk() ) - { - case _HEAPOK: - OSD_Printf( "OK - heap is good\n" ); - break; - case _HEAPEMPTY: - OSD_Printf( "OK - heap is empty\n" ); - break; - case _HEAPBADBEGIN: - OSD_Printf( "ERROR - heap is damaged\n" ); - break; - case _HEAPBADNODE: - OSD_Printf( "ERROR - bad node in heap\n" ); - break; - } - */ - OSD_Printf("JonoF: Not now"); -} - -/* -void heap_dump( void ) - { - struct _heapinfo h_info; - int heap_status; - - h_info._pentry = NULL; - for(;;) { - heap_status = _heapwalk( &h_info ); - if( heap_status != _HEAPOK ) break; - printf( " %s block at %Fp of size %4.4X\n", - (h_info._useflag == _USEDENTRY ? "USED" : "FREE"), - h_info._pentry, h_info._size ); - - } - - switch( heap_status ) { - case _HEAPEND: - printf( "OK - end of heap\n" ); - break; - case _HEAPEMPTY: - printf( "OK - heap is empty\n" ); - break; - case _HEAPBADBEGIN: - printf( "ERROR - heap is damaged\n" ); - break; - case _HEAPBADPTR: - printf( "ERROR - bad pointer to heap\n" ); - break; - case _HEAPBADNODE: - - printf( "ERROR - bad node in heap\n" ); - } - } - */ - -void CON_DumpHeap(void) -{ - //heap_dump(); // Dump it. - OSD_Printf("JonoF: Not now"); -} - void CON_ShowMirror(void) { char base[80]; @@ -1343,7 +410,6 @@ void CON_ShowMirror(void) if (sscanf(MessageInputString,"%s %hd",base,&op1) < 2) { strcpy(MessageInputString,"help showmirror"); - CON_GetHelp(); return; } @@ -1366,13 +432,5 @@ void CON_ShowMirror(void) OSD_Printf("mirror[%d].iscamera = %d",op1,mirror[op1].ismagic); } -void CON_DumpSoundList(void) -{ - extern void DumpSounds(void); - - DumpSounds(); - OSD_Printf("Sounds dumped to dbg.foo"); - -} END_SW_NS diff --git a/source/sw/src/miscactr.cpp b/source/sw/src/miscactr.cpp index f6cb36992..583cee325 100644 --- a/source/sw/src/miscactr.cpp +++ b/source/sw/src/miscactr.cpp @@ -748,7 +748,7 @@ int PachinkoLightOperate(short SpriteNum) // PACHINKO MACHINE #1 //////////////////////////////////////////////////////////////////// -SWBOOL Pachinko_Win_Cheat = FALSE; +CVAR(Bool, Pachinko_Win_Cheat, false, 0) ATTRIBUTE Pachinko1Attrib = { diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index b52b0f173..b62d47236 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -86,21 +86,6 @@ void SoundCallBack(unsigned int num); #define NUM_SAMPLES 10 -const char *BitNames[2] = -{ - "8-bit", "16-bit" -}; - -const char *ChannelNames[2] = -{ - "Mono", "Stereo" -}; - -const char *VoiceNames[8] = -{ - "1", "2", "3", "4", "5", "6", "7", "8" -}; - int music; int soundfx; int num_voices; @@ -139,101 +124,12 @@ AMB_INFO ambarray[] = #undef AMBIENT_TABLE #define MAX_AMBIENT_SOUNDS 82 -#define MAXSONGS 10 // This is the max songs per episode - SWBOOL OpenSound(VOC_INFOp vp, FileReader &handle, int *length); int ReadSound(FileReader & handle, VOC_INFOp vp, int length); // 3d sound engine function prototype VOC3D_INFOp Insert3DSound(void); -#if 0 -// DEBUG -char *globsndata[DIGI_MAX], *globvpdata[DIGI_MAX]; -int glength[DIGI_MAX]; -#endif - -/* -=================== -= -= My stuff -= -=================== -*/ - -int PlayerPainVocs[] = -{ - DIGI_PLAYERPAIN1, - DIGI_PLAYERPAIN2, - DIGI_PLAYERPAIN3, - DIGI_PLAYERPAIN4, - DIGI_PLAYERPAIN5 -}; - -// Don't have these sounds yet -int PlayerLowHealthPainVocs[] = -{ - DIGI_HURTBAD1, - DIGI_HURTBAD2, - DIGI_HURTBAD3, - DIGI_HURTBAD4, - DIGI_HURTBAD5 -}; - -int TauntAIVocs[] = -{ - DIGI_TAUNTAI1, - DIGI_TAUNTAI2, - DIGI_TAUNTAI3, - DIGI_TAUNTAI4, - DIGI_TAUNTAI5, - DIGI_TAUNTAI6, - DIGI_TAUNTAI7, - DIGI_TAUNTAI8, - DIGI_TAUNTAI9, - DIGI_TAUNTAI10, - DIGI_COWABUNGA, - DIGI_NOCHARADE, - DIGI_TIMETODIE, - DIGI_EATTHIS, - DIGI_FIRECRACKERUPASS, - DIGI_HOLYCOW, - DIGI_HAHA2, - DIGI_HOLYPEICESOFCOW, - DIGI_HOLYSHIT, - DIGI_HOLYPEICESOFSHIT, - DIGI_PAYINGATTENTION, - DIGI_EVERYBODYDEAD, - DIGI_KUNGFU, - DIGI_HOWYOULIKEMOVE, - DIGI_HAHA3, - DIGI_NOMESSWITHWANG, - DIGI_RAWREVENGE, - DIGI_YOULOOKSTUPID, - DIGI_TINYDICK, - DIGI_NOTOURNAMENT, - DIGI_WHOWANTSWANG, - DIGI_MOVELIKEYAK, - DIGI_ALLINREFLEXES -}; - -int PlayerGetItemVocs[] = -{ - DIGI_GOTITEM1, - DIGI_HAHA1, - DIGI_BANZAI, - DIGI_COWABUNGA, - DIGI_TIMETODIE -}; - -int PlayerYellVocs[] = -{ - DIGI_PLAYERYELL1, - DIGI_PLAYERYELL2, - DIGI_PLAYERYELL3 -}; - - // // Routine called when a sound is finished playing // @@ -255,10 +151,6 @@ SoundCallBack(intptr_t num) } vp = &voc[num]; - - // Update counter - //vp->playing--; - vp->lock--; } // @@ -266,13 +158,6 @@ SoundCallBack(intptr_t num) void ClearSoundLocks(void) { - unsigned i; - - for (i = 0; i < SIZ(voc); i++) - { - if (voc[i].lock >= 200) - voc[i].lock = 199; - } } void @@ -300,28 +185,6 @@ InitFX(void) FX_SetCallBack(SoundCallBack); } -extern short Level; -CVAR(Bool, sw_nothememidi, false, CVAR_ARCHIVE) - -SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. -{ - if (mapname == nullptr && song_file_name == nullptr && cdaudio_track == -1) - { - // Get the music defined for the current level. - - } - // Play CD audio if enabled. - if (cdaudio_track >= 0 && mus_redbook) - { - FStringf trackname("track%02d.ogg", cdaudio_track); - if (!Mus_Play(nullptr, trackname, true)) - { - buildprintf("Can't find CD track %i!\n", cdaudio_track); - } - } - else if (isThemeTrack && sw_nothememidi) return false; // The original SW source only used CD Audio for theme tracks, so this is optional. - return Mus_Play(nullptr, song_file_name, true); -} void StopFX(void) @@ -414,7 +277,6 @@ short SoundAngle(int x, int y) } int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp) -//PlayerSound(int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp) { int handle; VOC_INFOp vp; @@ -466,26 +328,6 @@ int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Vo void LockSound(int num) { - VOC_INFOp vp = &voc[num]; - // if data is not locked - if (vp->lock <= CACHE_UNLOCK_MAX) - { - vp->lock = CACHE_LOCK_START; - } - else - // if data is already locked - { - vp->lock++; - if (vp->lock >= CACHE_LOCK_MAX || vp->lock == 0) - { - DumpSounds(); - TerminateGame(); - printf("lock > MAX, num = %d",num); - exit(0); - } - //ASSERT(vp->lock < CACHE_LOCK_MAX); - //ASSERT(vp->lock != 0); - } } SWBOOL CacheSound(int num, int type) @@ -509,16 +351,6 @@ SWBOOL CacheSound(int num, int type) if (vp != NULL) { - //FILE *fp; - - /* - if (type == CACHE_SOUND_PLAY) - // start it out locked at the min - vp->lock = CACHE_LOCK_START; - else - if (type == CACHE_SOUND_PRECACHE) - // start it out unlocked at the max - */ vp->lock = CACHE_UNLOCK_MAX; cacheAllocateBlock((intptr_t*)&vp->data, length, &vp->lock); @@ -550,13 +382,6 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags) uint8_t priority; SPRITEp sp=NULL; - // DEBUG - //extern SWBOOL Pachinko_Win_Cheat; - - - // Don't play game sounds when in menus - //if (M_Active() && (*x!=0 || *y!=0 || *z!=0)) return(-1); - // Weed out parental lock sounds if PLock is active if (adult_lockout || Global_PLock) { @@ -732,16 +557,6 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags) else if (vp->pitch_hi != vp->pitch_lo) pitch = vp->pitch_lo + (STD_RANDOM_RANGE(vp->pitch_hi - vp->pitch_lo)); -#if 0 - // DEBUG - if (Pachinko_Win_Cheat) - { - CheckSndData(__FILE__, __LINE__); - Pachinko_Win_Cheat = FALSE; - CON_Message("S O U N D S C H E C K E D"); - } -#endif - // Request playback and play it as a looping sound if flag is set. if (vp->voc_flags & vf_loop) { @@ -987,15 +802,6 @@ DeleteNoSoundOwner(short spritenum) vp->handle = 0; } -#if 0 - // Clean up the sound active counter for cacheing locks - if (vp->FX_Ok) // Only decrement if sound ever played - vp->vp->playing--; // Decrement instance of sound playing - if (vp->vp->playing == 0 && vp->vp->lock > CACHE_UNLOCK_MAX) - vp->vp->lock = CACHE_UNLOCK_MAX; -#endif - - dp = vp; // Point to sound to be deleted if (vp->prev) @@ -1047,13 +853,6 @@ void DeleteNoFollowSoundOwner(short spritenum) vp->handle = 0; } -#if 0 - if (vp->FX_Ok) // Only decrement if sound ever played - vp->vp->playing--; // Decrement instance of sound playing - if (vp->vp->playing == 0 && vp->vp->lock > CACHE_UNLOCK_MAX) - vp->vp->lock = CACHE_UNLOCK_MAX; -#endif - dp = vp; // Point to sound to be deleted if (vp->prev) @@ -1102,17 +901,6 @@ Delete3DSounds(void) dp = NULL; if (vp->deleted) { -#if 0 - if (vp->FX_Ok) // Only decrement if sound ever played - vp->vp->playing--; // Decrement instance of sound playing - if (vp->vp->playing == 0 && vp->vp->lock > CACHE_UNLOCK_MAX) - vp->vp->lock = CACHE_UNLOCK_MAX; -#endif - - //DSPRINTF(ds,"Delete3DSounds: deleting owner %d digi %d\n",vp->owner,vp->num); - //MONO_PRINT(ds); - // Reset Player talking flag if a voice was deleted - //if(vp->num > DIGI_FIRSTPLAYERVOICE && vp->num < DIGI_LASTPLAYERVOICE) if (!vp->vp) { printf("Delete3DSounds(): NULL vp->vp\n"); @@ -1131,8 +919,6 @@ Delete3DSounds(void) pp->PlayerTalking = FALSE; pp->TalkVocnum = -1; pp->TalkVocHandle = -1; - //DSPRINTF(ds,"DELETED PLAYER VOICE VOC! NUM=%d\n",vp->num); - //MONO_PRINT(ds); } } } @@ -1488,9 +1274,6 @@ DoUpdateSounds3D(void) p = p->next; } // while(p) -// //DSPRINTF(ds,"Num vocs in list: %d, Sounds playing: %d\n",numelems,FX_SoundsPlaying()); -// MONO_PRINT(ds); - // Process all the looping sounds that said they wanted to get back in // Only update these sounds 5x per second! Woo hoo!, aren't we optimized now? //if(MoveSkip8==0) @@ -1510,12 +1293,8 @@ DoUpdateSounds3D(void) { if (p->owner == -1) { - int enumber; - enumber = p->num; - TerminateGame(); - printf("Owner == -1 on looping sound with follow flag set!\n"); - printf("p->num = %d\n",enumber); - exit(0); + // Terminate the sound without aborting. + continue; } Use_SoundSpriteNum = TRUE; @@ -1535,12 +1314,8 @@ DoUpdateSounds3D(void) { if (p->owner == -1) { - int enumber; - enumber = p->num; - TerminateGame(); - printf("Owner == -1 on looping sound, no follow flag.\n"); - printf("p->num = %d\n",enumber); - exit(0); + // Terminate the sound without aborting. + continue; } Use_SoundSpriteNum = TRUE; @@ -1553,11 +1328,8 @@ DoUpdateSounds3D(void) Use_SoundSpriteNum = FALSE; SoundSpriteNum = -1; - - //MONO_PRINT("TmpVocArray playing a non-follow sound"); } } - // } // MoveSkip8 // Clean out any deleted sounds now Delete3DSounds(); @@ -1586,30 +1358,6 @@ Terminate3DSounds(void) ClearSoundLocks(); } -void -DumpSounds(void) -{ - VOC3D_INFOp vp; - - vp = voc3dstart; - - while (vp) - { - if (TEST(vp->flags,v3df_ambient)) - sprintf(ds,"vp->num=%d, vp->owner=%d, vp->vp->lock=%d",ambarray[vp->num].diginame,vp->owner,vp->vp->lock); - else - sprintf(ds,"vp->num=%d, vp->owner=%d, vp->vp->lock=%d",vp->num,vp->owner,vp->vp->lock); - DebugWriteString(ds); - if (vp->owner >= 0) - { - SPRITEp sp = &sprite[vp->owner]; - sprintf(ds,"sp->picnum=%d, sp->hitag=%d, sp->lotag=%d, sp->owner=%d\n",TrackerCast(sp->picnum), TrackerCast(sp->hitag), TrackerCast(sp->lotag), TrackerCast(sp->owner)); - DebugWriteString(ds); - } - vp = vp->next; - } -} - ////////////////////////////////////////////////// // Set owner to check when to kill looping sounds @@ -1650,9 +1398,121 @@ PlaySpriteSound(short spritenum, int attrib_ndx, Voc3D_Flags flags) ASSERT(u); -// //DSPRINTF(ds,"index = %d, digi num = %d\n",attrib_ndx,u->Attrib->Sounds[attrib_ndx]); -// MONO_PRINT(ds); PlaySound(u->Attrib->Sounds[attrib_ndx], &sp->x, &sp->y, &sp->z, flags); } + + +/* +============================================================================ += += High level sound code (not directly engine related) += +============================================================================ +*/ + +int PlayerPainVocs[] = +{ + DIGI_PLAYERPAIN1, + DIGI_PLAYERPAIN2, + DIGI_PLAYERPAIN3, + DIGI_PLAYERPAIN4, + DIGI_PLAYERPAIN5 +}; + +// Don't have these sounds yet +int PlayerLowHealthPainVocs[] = +{ + DIGI_HURTBAD1, + DIGI_HURTBAD2, + DIGI_HURTBAD3, + DIGI_HURTBAD4, + DIGI_HURTBAD5 +}; + +int TauntAIVocs[] = +{ + DIGI_TAUNTAI1, + DIGI_TAUNTAI2, + DIGI_TAUNTAI3, + DIGI_TAUNTAI4, + DIGI_TAUNTAI5, + DIGI_TAUNTAI6, + DIGI_TAUNTAI7, + DIGI_TAUNTAI8, + DIGI_TAUNTAI9, + DIGI_TAUNTAI10, + DIGI_COWABUNGA, + DIGI_NOCHARADE, + DIGI_TIMETODIE, + DIGI_EATTHIS, + DIGI_FIRECRACKERUPASS, + DIGI_HOLYCOW, + DIGI_HAHA2, + DIGI_HOLYPEICESOFCOW, + DIGI_HOLYSHIT, + DIGI_HOLYPEICESOFSHIT, + DIGI_PAYINGATTENTION, + DIGI_EVERYBODYDEAD, + DIGI_KUNGFU, + DIGI_HOWYOULIKEMOVE, + DIGI_HAHA3, + DIGI_NOMESSWITHWANG, + DIGI_RAWREVENGE, + DIGI_YOULOOKSTUPID, + DIGI_TINYDICK, + DIGI_NOTOURNAMENT, + DIGI_WHOWANTSWANG, + DIGI_MOVELIKEYAK, + DIGI_ALLINREFLEXES +}; + +int PlayerGetItemVocs[] = +{ + DIGI_GOTITEM1, + DIGI_HAHA1, + DIGI_BANZAI, + DIGI_COWABUNGA, + DIGI_TIMETODIE +}; + +int PlayerYellVocs[] = +{ + DIGI_PLAYERYELL1, + DIGI_PLAYERYELL2, + DIGI_PLAYERYELL3 +}; + +/* +============================================================================ += += PLays music += +============================================================================ +*/ + +extern short Level; +CVAR(Bool, sw_nothememidi, false, CVAR_ARCHIVE) + +SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. +{ + if (mapname == nullptr && song_file_name == nullptr && cdaudio_track == -1) + { + // Get the music defined for the current level. + + } + // Play CD audio if enabled. + if (cdaudio_track >= 0 && mus_redbook) + { + FStringf trackname("track%02d.ogg", cdaudio_track); + if (!Mus_Play(nullptr, trackname, true)) + { + buildprintf("Can't find CD track %i!\n", cdaudio_track); + } + } + else if (isThemeTrack && sw_nothememidi) return false; // The original SW source only used CD Audio for theme tracks, so this is optional. + return Mus_Play(nullptr, song_file_name, true); +} + + END_SW_NS