Skip to content

Commit

Permalink
- engine side preparations for Duke Statusbar scriptification.
Browse files Browse the repository at this point in the history
Mainly, gotweapon had to be reverted to a flat bool array to avoid implementing FixedBitArray for the VM.
Also adding a few new tile names and PushV for string arrays.
  • Loading branch information
coelckers committed May 15, 2021
1 parent 845ce63 commit d311792
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 64 deletions.
16 changes: 16 additions & 0 deletions source/common/scripting/core/dynarrays.cpp
Expand Up @@ -1006,6 +1006,22 @@ DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Push, ArrayPush<FDynArray_String
ACTION_RETURN_INT(self->Push(val));
}

DEFINE_ACTION_FUNCTION(FDynArray_String, PushV)
{
PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String);
PARAM_VA_POINTER(va_reginfo); // Get the hidden type information array
VMVa_List args = { param + 1, 0, numparam - 2, va_reginfo + 1 };
while (args.curindex < args.numargs)
{
if (args.reginfo[args.curindex] == REGT_STRING)
{
self->Push(args.args[args.curindex++].s());
}
else ThrowAbortException(X_OTHER, "Invalid parameter in pushv, string expected");
}
ACTION_RETURN_INT(self->Size() - 1);
}

DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Pop, ArrayPop<FDynArray_String>)
{
PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String);
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/2d_d.cpp
Expand Up @@ -112,9 +112,9 @@ void InitFonts_d()
fontdata.Clear();

// SBAR index font
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE + i));
fontdata.Insert(':', tileGetTexture(THREEBYFIVE + 10));
fontdata.Insert('/', tileGetTexture(THREEBYFIVE + 11));
for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE0 + i));
fontdata.Insert(':', tileGetTexture(THREEBYFIVE0 + 10));
fontdata.Insert('/', tileGetTexture(THREEBYFIVE0 + 11));
fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!'));
fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation.
GlyphSet::Iterator iti(fontdata);
Expand Down
6 changes: 3 additions & 3 deletions source/games/duke/src/actors_d.cpp
Expand Up @@ -220,9 +220,9 @@ void addweapon_d(struct player_struct *p, int weapon)
{
if ( p->gotweapon[weapon] == 0 )
{
p->gotweapon.Set(weapon);
if(weapon == SHRINKER_WEAPON)
p->gotweapon.Set(GROW_WEAPON);
p->gotweapon[weapon] = true;
if (weapon == SHRINKER_WEAPON)
p->gotweapon[GROW_WEAPON] = true;
}

p->random_club_frame = 0;
Expand Down
16 changes: 8 additions & 8 deletions source/games/duke/src/actors_r.cpp
Expand Up @@ -118,16 +118,16 @@ void addweapon_r(struct player_struct* p, int weapon)
short cw = p->curr_weapon;
if (p->OnMotorcycle || p->OnBoat)
{
p->gotweapon.Set(weapon);
p->gotweapon[weapon] = true;;
if (weapon == THROWSAW_WEAPON)
{
p->gotweapon.Set(BUZZSAW_WEAPON);
p->gotweapon[BUZZSAW_WEAPON] = true;
p->ammo_amount[BUZZSAW_WEAPON] = 1;
}
else if (weapon == CROSSBOW_WEAPON)
{
p->gotweapon.Set(CHICKEN_WEAPON);
p->gotweapon.Set(DYNAMITE_WEAPON);
p->gotweapon[CHICKEN_WEAPON] = true;
p->gotweapon[DYNAMITE_WEAPON] = true;
}
else if (weapon == SLINGBLADE_WEAPON)
{
Expand All @@ -138,17 +138,17 @@ void addweapon_r(struct player_struct* p, int weapon)

if (p->gotweapon[weapon] == 0)
{
p->gotweapon.Set(weapon);
p->gotweapon[weapon] = true;;
if (weapon == THROWSAW_WEAPON)
{
p->gotweapon.Set(BUZZSAW_WEAPON);
p->gotweapon[BUZZSAW_WEAPON] = true;
p->ammo_amount[BUZZSAW_WEAPON] = 1;
}
if (isRRRA())
{
if (weapon == CROSSBOW_WEAPON)
{
p->gotweapon.Set(CHICKEN_WEAPON);
p->gotweapon[CHICKEN_WEAPON] = true;
}
if (weapon == SLINGBLADE_WEAPON)
{
Expand All @@ -157,7 +157,7 @@ void addweapon_r(struct player_struct* p, int weapon)
}
if (weapon == CROSSBOW_WEAPON)
{
p->gotweapon.Set(DYNAMITE_WEAPON);
p->gotweapon[DYNAMITE_WEAPON] = true;
}

if (weapon != DYNAMITE_WEAPON)
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/cheats.cpp
Expand Up @@ -194,7 +194,7 @@ const char* GameInterface::GenericCheat(int player, int cheat)

case CHT_RHETT:
ud.god = 0;
ps[player].gotweapon.Zero();
memset(ps[player].gotweapon, 0, MAX_WEAPONS);
ps[player].curr_weapon = KNEE_WEAPON;
ps[player].nocheat = 1;
ps[player].GetActor()->s->extra = 1;
Expand Down Expand Up @@ -231,7 +231,7 @@ static bool cheatWeapons(int player)
for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ )
{
addammo( weapon, &ps[player], gs.max_ammo_amount[weapon] );
ps[player].gotweapon.Set(weapon);
ps[player].gotweapon[weapon] = true;;
}
if (isRRRA())
ps[player].ammo_amount[SLINGBLADE_WEAPON] = 1;
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/flags_r.cpp
Expand Up @@ -173,7 +173,7 @@ void initactorflags_r()
STEROIDS,
HEATSENSOR,
BOOTS,
JETPACK,
COWPIE,
HOLODUKE,
AIRTANK });

Expand Down Expand Up @@ -205,7 +205,7 @@ void initactorflags_r()
gs.weaponsandammosprites[2] = DEVISTATORAMMO;
gs.weaponsandammosprites[3] = RPGAMMO;
gs.weaponsandammosprites[4] = RPGAMMO;
gs.weaponsandammosprites[5] = JETPACK;
gs.weaponsandammosprites[5] = COWPIE;
gs.weaponsandammosprites[6] = SHIELD;
gs.weaponsandammosprites[7] = FIRSTAID;
gs.weaponsandammosprites[8] = STEROIDS;
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/gameexec.cpp
Expand Up @@ -851,7 +851,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
break;

case PLAYER_GOTWEAPON:
if (bSet) ps[iPlayer].gotweapon.Set(lParm2, lValue);
if (bSet) ps[iPlayer].gotweapon[lParm2, lValue] = true;
else SetGameVarID(lVar2, ps[iPlayer].gotweapon[lParm2], sActor, sPlayer);
break;

Expand Down
25 changes: 24 additions & 1 deletion source/games/duke/src/namelist_d.h
Expand Up @@ -13,6 +13,7 @@ x(AMMOBOX, 31)
x(GROWSPRITEICON, 32)
x(INVENTORYBOX, 33)
x(FREEZEAMMO, 37)
x(FREEZEAMMO1, 38)
x(AMMO, 40)
x(BATTERYAMMO, 41)
x(DEVISTATORAMMO, 42)
Expand Down Expand Up @@ -571,14 +572,35 @@ x(BIGFNTCURSOR, 2820)
x(SMALLFNTCURSOR, 2821)
x(STARTALPHANUM, 2822)
x(ENDALPHANUM, 2915)
x(BIGALPHANUM0, 2930)
x(BIGALPHANUM1, 2931)
x(BIGALPHANUM2, 2932)
x(BIGALPHANUM3, 2933)
x(BIGALPHANUM4, 2934)
x(BIGALPHANUM5, 2935)
x(BIGALPHANUM6, 2936)
x(BIGALPHANUM7, 2937)
x(BIGALPHANUM8, 2938)
x(BIGALPHANUM9, 2939)
x(BIGALPHANUM, 2940)
x(BIGPERIOD, 3002)
x(BIGCOMMA, 3003)
x(BIGX, 3004)
x(BIGQ, 3005)
x(BIGSEMI, 3006)
x(BIGCOLIN, 3007)
x(THREEBYFIVE, 3010)
x(THREEBYFIVE0, 3010)
x(THREEBYFIVE1, 3011)
x(THREEBYFIVE2, 3012)
x(THREEBYFIVE3, 3013)
x(THREEBYFIVE4, 3014)
x(THREEBYFIVE5, 3015)
x(THREEBYFIVE6, 3016)
x(THREEBYFIVE7, 3017)
x(THREEBYFIVE8, 3018)
x(THREEBYFIVE9, 3019)
x(THREEBYFIVE10, 3020)
x(THREEBYFIVE11, 3021)
x(BIGAPPOS, 3022)
x(BLANK, 3026)
x(MINIFONT, 3072)
Expand Down Expand Up @@ -766,6 +788,7 @@ x(WTGLASS1, 5736)
x(WTGLASS2, 5737)
x(FLAMETHROWERSPRITE, 5134)
x(FLAMETHROWERAMMO, 5135)
x(FLAMETHROWERAMMO1, 5136)
x(FLAMETHROWER, 5138)
x(ONFIRE, 5152)
x(LAVAPOOL, 5304)
Expand Down
16 changes: 13 additions & 3 deletions source/games/duke/src/namelist_r.h
Expand Up @@ -35,13 +35,13 @@ x(CRYSTALAMMO, 46)
x(HBOMBAMMO, 47)
x(AMMOLOTS, 48)
x(SHOTGUNAMMO, 49)
x(COLA, 51)
x(BEER, 51)
x(SIXPAK, 52)
x(FIRSTAID, 53)
x(SHIELD, 54)
x(STEROIDS, 55)
x(AIRTANK, 56)
x(JETPACK, 57)
x(COWPIE, 57)
x(HEATSENSOR, 59)
x(ACCESSCARD, 60)
x(BOOTS, 61)
Expand Down Expand Up @@ -229,7 +229,17 @@ x(GUTMETER_LIGHT1, 920)
x(GUTMETER_LIGHT2, 921)
x(GUTMETER_LIGHT3, 922)
x(GUTMETER_LIGHT4, 923)
x(AMMO_ICON, 930)
x(AMMO_ICON0, 930)
x(AMMO_ICON1, 931)
x(AMMO_ICON2, 932)
x(AMMO_ICON3, 933)
x(AMMO_ICON4, 934)
x(AMMO_ICON5, 935)
x(AMMO_ICON6, 936)
x(AMMO_ICON7, 937)
x(AMMO_ICON8, 938)
x(AMMO_ICON9, 939)
x(AMMO_ICON10, 940)
x(CLOUDYSKIES, 1021)
x(MOONSKY1, 1022)
x(MOONSKY2, 1023)
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/player_d.cpp
Expand Up @@ -1315,7 +1315,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
{
if (act->s->picnum == HEAVYHBOMB && act->GetOwner() == p->GetActor())
{
p->gotweapon.Set(HANDBOMB_WEAPON);
p->gotweapon[HANDBOMB_WEAPON] = true;
j = HANDREMOTE_WEAPON;
break;
}
Expand Down
18 changes: 9 additions & 9 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -1082,7 +1082,7 @@ void selectweapon_r(int snum, int weap)
{
if (act->s->picnum == HEAVYHBOMB && act->GetOwner() == p->GetActor())
{
p->gotweapon.Set(DYNAMITE_WEAPON);
p->gotweapon[DYNAMITE_WEAPON] = true;
j = THROWINGDYNAMITE_WEAPON;
break;
}
Expand Down Expand Up @@ -1499,7 +1499,7 @@ void checkweapons_r(struct player_struct* p)
j->s->ang = p->angle.ang.asbuild();
j->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON];
p->OnMotorcycle = 0;
p->gotweapon.Clear(MOTORCYCLE_WEAPON);
p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->horizon.horiz = q16horiz(0);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
Expand All @@ -1515,7 +1515,7 @@ void checkweapons_r(struct player_struct* p)
j->s->ang = p->angle.ang.asbuild();
j->saved_ammo = p->ammo_amount[BOAT_WEAPON];
p->OnBoat = 0;
p->gotweapon.Clear(BOAT_WEAPON);
p->gotweapon[BOAT_WEAPON] = false;
p->horizon.horiz = q16horiz(0);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
Expand Down Expand Up @@ -3132,7 +3132,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
if (p->kickback_pic == 3)
{
p->ammo_amount[POWDERKEG_WEAPON]--;
p->gotweapon.Clear(POWDERKEG_WEAPON);
p->gotweapon[POWDERKEG_WEAPON] = false;
if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle)
{
k = 15;
Expand Down Expand Up @@ -3176,7 +3176,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect)
if (p->kickback_pic > 40)
{
p->okickback_pic = p->kickback_pic = 0;
p->gotweapon.Clear(BOWLING_WEAPON);
p->gotweapon[BOWLING_WEAPON] = false;
checkavailweapon(p);
}
break;
Expand Down Expand Up @@ -4057,7 +4057,7 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite)
p->OnMotorcycle = 1;
p->last_full_weapon = p->curr_weapon;
p->curr_weapon = MOTORCYCLE_WEAPON;
p->gotweapon.Set(MOTORCYCLE_WEAPON);
p->gotweapon[MOTORCYCLE_WEAPON] = true;
p->posxv = 0;
p->posyv = 0;
p->horizon.horiz = q16horiz(0);
Expand Down Expand Up @@ -4088,7 +4088,7 @@ void OffMotorcycle(struct player_struct *p)
if (!S_CheckActorSoundPlaying(pact,42))
S_PlayActorSound(42, pact);
p->OnMotorcycle = 0;
p->gotweapon.Clear(MOTORCYCLE_WEAPON);
p->gotweapon[MOTORCYCLE_WEAPON] = false;
p->curr_weapon = p->last_full_weapon;
checkavailweapon(p);
p->horizon.horiz = q16horiz(0);
Expand Down Expand Up @@ -4134,7 +4134,7 @@ void OnBoat(struct player_struct *p, DDukeActor* boat)
p->OnBoat = 1;
p->last_full_weapon = p->curr_weapon;
p->curr_weapon = BOAT_WEAPON;
p->gotweapon.Set(BOAT_WEAPON);
p->gotweapon[BOAT_WEAPON] = true;
p->posxv = 0;
p->posyv = 0;
p->horizon.horiz = q16horiz(0);
Expand All @@ -4152,7 +4152,7 @@ void OffBoat(struct player_struct *p)
if (p->OnBoat)
{
p->OnBoat = 0;
p->gotweapon.Clear(BOAT_WEAPON);
p->gotweapon[BOAT_WEAPON] = false;
p->curr_weapon = p->last_full_weapon;
checkavailweapon(p);
p->horizon.horiz = q16horiz(0);
Expand Down

0 comments on commit d311792

Please sign in to comment.