Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to set up more than one Laptop Gun sentry #446

Draft
wants to merge 1 commit into
base: port
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/game/propobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ s32 g_LastPadEffectIndex = -1;
struct autogunobj *g_ThrownLaptops = NULL;
struct beam *g_ThrownLaptopBeams = NULL;
s32 g_MaxThrownLaptops = 0;
s32 g_MaxThrownLaptopsPerPlayer = 1000;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each user can now set up up to 1000 sentry guns


/**
* Attempt to call a lift from the given door.
Expand Down Expand Up @@ -18471,7 +18472,12 @@ struct autogunobj *laptopDeploy(s32 modelnum, struct gset *gset, struct chrdata
if (index >= 0 && index < g_MaxThrownLaptops) {
setupLoadModeldef(modelnum);
modeldef = g_ModelStates[modelnum].modeldef;
laptop = &g_ThrownLaptops[index];
s32 laptopIndex = index * g_MaxThrownLaptopsPerPlayer;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is when the user sets up a new sentry. All sentries are stored in one big array, so now that each player can have multiple, let's multiply the player index with the number of sentries per player to find the start of the searching space. Then let's iterate over the space allocated for that user until we find a free space to store that new sentry gun in memory.


do {
laptop = &g_ThrownLaptops[laptopIndex];
laptopIndex++;
} while (laptop->base.prop);

if (laptop->base.prop) {
#if VERSION >= VERSION_NTSC_1_0
Expand Down
2 changes: 1 addition & 1 deletion src/game/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void propsReset(void)
g_AutogunDamageRxScale = 1;
g_AmmoQuantityScale = 1;

g_MaxThrownLaptops = g_Vars.normmplayerisrunning ? 12 : PLAYERCOUNT();
g_MaxThrownLaptops = (g_Vars.normmplayerisrunning ? 12 : PLAYERCOUNT()) * g_MaxThrownLaptopsPerPlayer;

g_ThrownLaptops = mempAlloc(ALIGN16(g_MaxThrownLaptops * sizeof(struct autogunobj)), MEMPOOL_STAGE);
g_ThrownLaptopBeams = mempAlloc(ALIGN16(g_MaxThrownLaptops * sizeof(struct beam)), MEMPOOL_STAGE);
Expand Down
1 change: 1 addition & 0 deletions src/include/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ extern s32 g_LastPadEffectIndex;
extern struct autogunobj *g_ThrownLaptops;
extern struct beam *g_ThrownLaptopBeams;
extern s32 g_MaxThrownLaptops;
extern s32 g_MaxThrownLaptopsPerPlayer;
extern struct prop *g_Lifts[10];
extern u32 g_TvCmdlist00[];
extern u32 var8006aaa0[];
Expand Down