- use the quote array to store the key, door and fortune cookie messages in Shadow Warrior.

This is infinitely better than leaking char pointers.
This commit is contained in:
Christoph Oelckers 2019-12-09 18:40:07 +01:00
parent 782dfcdc54
commit 670c8b1408
9 changed files with 94 additions and 104 deletions

View file

@ -961,12 +961,18 @@ extern const char *ThemeSongs[6]; //
extern char EpisodeNames[3][MAX_EPISODE_NAME_LEN+2];
#define MAX_FORTUNES 16
extern const char *ReadFortune[MAX_FORTUNES];
#define MAX_KEYS 8
extern const char *KeyMsg[MAX_KEYS];
extern const char *KeyDoorMessage[MAX_KEYS];
enum
{
MAX_KEYS = 8,
MAX_FORTUNES = 16,
QUOTE_KEYMSG = 1,
QUOTE_DOORMSG = QUOTE_KEYMSG + MAX_KEYS,
// 23+24 are reserved.
QUOTE_COOKIE = 25,
};
typedef struct
{

View file

@ -35,6 +35,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "text.h"
#include "interp.h"
#include "sprite.h"
#include "quotemgr.h"
BEGIN_SW_NS
@ -217,7 +218,7 @@ DoRotatorMatch(PLAYERp pp, short match, SWBOOL manual)
else
#endif
{
PutStringInfo(pp, KeyDoorMessage[key_num - 1]);
PutStringInfo(pp, quoteMgr.GetExQuote(QUOTE_DOORMSG + key_num - 1));
return -1;
}
}

View file

@ -40,6 +40,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "parent.h"
#include "scriptfile.h"
#include "menu/menu.h"
#include "quotemgr.h"
BEGIN_SW_NS
@ -538,9 +539,6 @@ static int cm_transtok(const char *tok, const struct _tokset *set, const unsigne
// quit "PRESS (Y) TO QUIT, (N) TO FIGHT ON."
static LEVEL_INFO custommaps[MAX_LEVELS_REG];
static char *customfortune[MAX_FORTUNES];
static char *customkeymsg[MAX_KEYS];
static char *customkeydoormsg[MAX_KEYS];
static char *custominventoryname[InvDecl_TOTAL];
static char *customweaponname[2][MAX_WEAPONS]; // weapon, ammo
@ -798,8 +796,7 @@ void LoadCustomInfoFromScript(const char *filename)
if (fc == MAX_FORTUNES) continue;
customfortune[fc] = strdup(t);
if (customfortune[fc]) ReadFortune[fc] = customfortune[fc];
quoteMgr.InitializeQuote(QUOTE_COOKIE + fc, t);
fc++;
}
break;
@ -817,8 +814,7 @@ void LoadCustomInfoFromScript(const char *filename)
if (fc == MAX_KEYS) continue;
customkeymsg[fc] = strdup(t);
if (customkeymsg[fc]) KeyMsg[fc] = customkeymsg[fc];
quoteMgr.InitializeQuote(QUOTE_KEYMSG + fc, t);
fc++;
}
break;
@ -836,8 +832,7 @@ void LoadCustomInfoFromScript(const char *filename)
if (fc == MAX_KEYS) continue;
customkeydoormsg[fc] = strdup(t);
if (customkeydoormsg[fc]) KeyDoorMessage[fc] = customkeydoormsg[fc];
quoteMgr.InitializeQuote(QUOTE_DOORMSG + fc, t);
fc++;
}
break;

View file

@ -36,6 +36,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "interp.h"
#include "text.h"
#include "sprite.h"
#include "quotemgr.h"
BEGIN_SW_NS
@ -213,7 +214,7 @@ DoSlidorMatch(PLAYERp pp, short match, SWBOOL manual)
else
#endif
{
PutStringInfo(pp, KeyDoorMessage[key_num - 1]);
PutStringInfo(pp, quoteMgr.GetExQuote(QUOTE_DOORMSG + key_num - 1));
return -1;
}
}

View file

@ -48,6 +48,8 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "slidor.h"
#include "player.h"
#include "swcvar.h"
#include "quotemgr.h"
#include "v_text.h"
BEGIN_SW_NS
@ -5505,29 +5507,6 @@ void ChoosePlayerGetSound(PLAYERp pp)
PlayerSound(PlayerGetItemVocs[choose_snd],&pp->posx,&pp->posy,&pp->posz,v3df_follow|v3df_dontpan,pp);
}
//#define MAX_FORTUNES 16
// With PLOCK on, max = 11
const char *ReadFortune[MAX_FORTUNES] =
{
"You never going to score.",
"26-31-43-82-16-29",
"Sorry, you no win this time, try again.",
"You try harder get along. Be a nice man.",
"No man is island, except Lo Wang.",
"There is much death in future.",
"You should kill all business associates.",
"(c)1997,3DRealms fortune cookie company.",
"Your chi attracts many chicks.",
"Don't you know you the scum of society!?",
"You should not scratch yourself there.",
"Man who stand on toilet, high on pot.",
"Man who fart in church sit in own pew.",
"Man trapped in pantry has ass in jam.",
"Baseball wrong. Man with 4 balls cannot walk.",
"Man who buy drowned cat pay for wet pussy.",
};
SWBOOL CanGetWeapon(PLAYERp pp, short SpriteNum, int WPN)
{
USERp u = User[SpriteNum], pu;
@ -5563,18 +5542,6 @@ SWBOOL CanGetWeapon(PLAYERp pp, short SpriteNum, int WPN)
return TRUE;
}
const char *KeyMsg[MAX_KEYS] =
{
"Got the RED key!",
"Got the BLUE key!",
"Got the GREEN key!",
"Got the YELLOW key!",
"Got the GOLD master key!",
"Got the SILVER master key!",
"Got the BRONZE master key!",
"Got the RED master key!"
};
struct InventoryDecl_t InventoryDecls[InvDecl_TOTAL] =
{
{ "Armor Vest +50", 50 },
@ -5702,7 +5669,7 @@ KeyMain:
if (pp->HasKey[key_num])
break;
PutStringInfo(Player+pnum, KeyMsg[key_num]);
PutStringInfo(Player+pnum, quoteMgr.GetQuote(QUOTE_KEYMSG + key_num));
pp->HasKey[key_num] = TRUE;
SetFadeAmt(pp,ITEMFLASHAMT,ITEMFLASHCLR); // Flash blue on item pickup
@ -5795,11 +5762,9 @@ KeyMain:
// Say something witty
if (pp == Player+myconnectindex && hud_messages)
{
if (adult_lockout || Global_PLock)
sprintf(ds,"Fortune Say: %s\n",ReadFortune[STD_RANDOM_RANGE(10)]);
else
sprintf(ds,"Fortune Say: %s\n",ReadFortune[STD_RANDOM_RANGE(MAX_FORTUNES)]);
OSD_Printf("%s", ds);
int cookie = (adult_lockout || Global_PLock)? STD_RANDOM_RANGE(10) : STD_RANDOM_RANGE(MAX_FORTUNES);
// print to the console, and if active to the generic notify display.
Printf(PRINT_NOTIFY, TEXTCOLOR_SAPPHIRE "%s: %s\n", GStrings("TXTS_FORTUNE"), quoteMgr.GetQuote(QUOTE_COOKIE + cookie));
}
SetFadeAmt(pp,ITEMFLASHAMT,ITEMFLASHCLR); // Flash blue on item pickup

View file

@ -49,18 +49,6 @@ BEGIN_SW_NS
#define PANEL_SM_FONT_Y 3613
#define PANEL_SM_FONT_R 3625
const char *KeyDoorMessage[MAX_KEYS] =
{
"You need a RED key for this door.",
"You need a BLUE key for this door.",
"You need a GREEN key for this door.",
"You need a YELLOW key for this door.",
"You need a GOLD key for this door.",
"You need a SILVER key for this door.",
"You need a BRONZE key for this door.",
"You need a RED key for this door."
};
void DisplaySummaryString(PLAYERp pp, short xs, short ys, short color, short shade, const char *buffer)
{
short size,x;

View file

@ -36,6 +36,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "text.h"
#include "sprite.h"
#include "weapon.h"
#include "quotemgr.h"
BEGIN_SW_NS
@ -199,7 +200,7 @@ short DoVatorOperate(PLAYERp pp, short sectnum)
else
#endif
{
PutStringInfo(pp, KeyDoorMessage[key_num - 1]);
PutStringInfo(pp, quoteMgr.GetExQuote(QUOTE_DOORMSG + key_num - 1));
return FALSE;
}
}
@ -267,7 +268,7 @@ DoVatorMatch(PLAYERp pp, short match)
else
#endif
{
PutStringInfo(pp, KeyDoorMessage[key_num - 1]);
PutStringInfo(pp, quoteMgr.GetExQuote(QUOTE_DOORMSG + key_num - 1));
return -1;
}
}

View file

@ -1776,3 +1776,36 @@ TXTS_SK1,Tiny grasshopper,,,,,,,,,,,,,,,,,,,,,,
TXTS_SK2,I Have No Fear,,,,,,,,,,,,,,,,,,,,,,
TXTS_SK3,Who Wants Wang,,,,,,,,,,,,,,,,,,,,,,
TXTS_SK4,"No Pain, No Gain",,,,,,,,,,,,,,,,,,,,,,
Got the RED key!,TXTS_KEY1,,,,,,,,,,,,,,,,,,,,,,
Got the BLUE key!,TXTS_KEY2,,,,,,,,,,,,,,,,,,,,,,
Got the GREEN key!,TXTS_KEY3,,,,,,,,,,,,,,,,,,,,,,
Got the YELLOW key!,TXTS_KEY4,,,,,,,,,,,,,,,,,,,,,,
Got the GOLD master key!,TXTS_KEY5,,,,,,,,,,,,,,,,,,,,,,
Got the SILVER master key!,TXTS_KEY6,,,,,,,,,,,,,,,,,,,,,,
Got the BRONZE master key!,TXTS_KEY7,,,,,,,,,,,,,,,,,,,,,,
Got the RED master key!,TXTS_KEY8,,,,,,,,,,,,,,,,,,,,,,
You need a RED key for this door.,TXTS_DOOR1,,,,,,,,,,,,,,,,,,,,,,
You need a BLUE key for this door.,TXTS_DOOR2,,,,,,,,,,,,,,,,,,,,,,
You need a GREEN key for this door.,TXTS_DOOR3,,,,,,,,,,,,,,,,,,,,,,
You need a YELLOW key for this door.,TXTS_DOOR4,,,,,,,,,,,,,,,,,,,,,,
You need a GOLD key for this door.,TXTS_DOOR5,,,,,,,,,,,,,,,,,,,,,,
You need a SILVER key for this door.,TXTS_DOOR6,,,,,,,,,,,,,,,,,,,,,,
You need a BRONZE key for this door.,TXTS_DOOR7,,,,,,,,,,,,,,,,,,,,,,
You need a RED key for this door.,TXTS_DOOR8,,,,,,,,,,,,,,,,,,,,,,
You never going to score.,TXTS_COOKIE1,,,,,,,,,,,,,,,,,,,,,,
26-31-43-82-16-29,TXTS_COOKIE2,,,,,,,,,,,,,,,,,,,,,,
"Sorry, you no win this time, try again.",TXTS_COOKIE3,,,,,,,,,,,,,,,,,,,,,,
You try harder get along. Be a nice man.,TXTS_COOKIE4,,,,,,,,,,,,,,,,,,,,,,
"No man is island, except Lo Wang.",TXTS_COOKIE5,,,,,,,,,,,,,,,,,,,,,,
There is much death in future.,TXTS_COOKIE6,,,,,,,,,,,,,,,,,,,,,,
You should kill all business associates.,TXTS_COOKIE7,,,,,,,,,,,,,,,,,,,,,,
"(c)1997,3DRealms fortune cookie company.",TXTS_COOKIE8,,,,,,,,,,,,,,,,,,,,,,
Your chi attracts many chicks.,TXTS_COOKIE9,,,,,,,,,,,,,,,,,,,,,,
Don't you know you the scum of society!?,TXTS_COOKIE10,,,,,,,,,,,,,,,,,,,,,,
You should not scratch yourself there.,TXTS_COOKIE11,,,,,,,,,,,,,,,,,,,,,,
"Man who stand on toilet, high on pot.",TXTS_COOKIE12,,,,,,,,,,,,,,,,,,,,,,
Man who fart in church sit in own pew.,TXTS_COOKIE13,,,,,,,,,,,,,,,,,,,,,,
Man trapped in pantry has ass in jam.,TXTS_COOKIE14,,,,,,,,,,,,,,,,,,,,,,
Baseball wrong. Man with 4 balls cannot walk.,TXTS_COOKIE15,,,,,,,,,,,,,,,,,,,,,,
Man who buy drowned cat pay for wet pussy.,TXTS_COOKIE16,,,,,,,,,,,,,,,,,,,,,,
Fortune Say:,TXTS_FORTUNE,,,,,,,,,,,,,,,,,,,,,,
1 default Identifier Remarks Filter eng enc ena enz eni ens enj enb enl ent enw cs de el eo es esm esn esg esc esa esd esv eso esr ess esf esl esy esz esb ese esh esi esu fi fr hu it jp ko nl pl pt ptg ro ru sr
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811

View file

@ -446,44 +446,44 @@ weapon 12
}
fortune
{
"You never going to score."
"26-31-43-82-16-29"
"Sorry, you no win this time, try again."
"You try harder get along. Be a nice man."
"No man is island, except Lo Wang."
"There is much death in future."
"You should kill all business associates."
"(c)1997,3DRealms fortune cookie company."
"Your chi attracts many chicks."
"Don't you know you the scum of society!?"
"You should not scratch yourself there."
"Man who stand on toilet, high on pot."
"Man who fart in church sit in own pew."
"Man trapped in pantry has ass in jam."
"Baseball wrong. Man with 4 balls cannot walk."
"Man who buy drowned cat pay for wet pussy."
"$TXTS_COOKIE1"
"$TXTS_COOKIE2"
"$TXTS_COOKIE3"
"$TXTS_COOKIE4"
"$TXTS_COOKIE5"
"$TXTS_COOKIE6"
"$TXTS_COOKIE7"
"$TXTS_COOKIE8"
"$TXTS_COOKIE9"
"$TXTS_COOKIE10"
"$TXTS_COOKIE11"
"$TXTS_COOKIE12"
"$TXTS_COOKIE13"
"$TXTS_COOKIE14"
"$TXTS_COOKIE15"
"$TXTS_COOKIE16"
}
gotkey
{
"Got the RED key!"
"Got the BLUE key!"
"Got the GREEN key!"
"Got the YELLOW key!"
"Got the GOLD master key!"
"Got the SILVER master key!"
"Got the BRONZE master key!"
"Got the RED master key!"
"$TXTS_KEY1"
"$TXTS_KEY2"
"$TXTS_KEY3"
"$TXTS_KEY4"
"$TXTS_KEY5"
"$TXTS_KEY6"
"$TXTS_KEY7"
"$TXTS_KEY8"
}
needkey
{
"You need a RED key for this door."
"You need a BLUE key for this door."
"You need a GREEN key for this door."
"You need a YELLOW key for this door."
"You need a GOLD key for this door."
"You need a SILVER key for this door."
"You need a BRONZE key for this door."
"You need a RED key for this door."
"$TXTS_DOOR1"
"$TXTS_DOOR2"
"$TXTS_DOOR3"
"$TXTS_DOOR4"
"$TXTS_DOOR5"
"$TXTS_DOOR6"
"$TXTS_DOOR7"
"$TXTS_DOOR8"
}
theme 1 // game startup menu
{