Skip to content

Commit e136619

Browse files
escape209SquareMan
authored andcommitted
A few matches (zGrid, zNPC)
1 parent d81297b commit e136619

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

src/SB/Core/x/xGrid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef S32 (*GridEntCallback)(xEnt*, void*);
6262
extern volatile S32 gGridIterActive;
6363

6464
void xGridBoundInit(xGridBound* gridb, void* data);
65+
void xGridKill(xGrid* grid);
6566
void xGridEmpty(xGrid* grid);
6667
S32 xGridRemove(xGridBound* gridb);
6768
xGridBound** xGridGetCell(xGrid* grid, const xEnt* ent, S32& grx, S32& grz);

src/SB/Game/zGrid.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
#include "zGrid.h"
2+
#include "xGrid.h"
3+
#include "xString.h"
24

35
#include <types.h>
6+
7+
xGrid colls_grid;
8+
xGrid colls_oso_grid;
9+
xGrid npcs_grid;
10+
static int zGridInitted;
11+
12+
void zGridExit(zScene* s)
13+
{
14+
xGridKill(&colls_grid);
15+
xGridKill(&colls_oso_grid);
16+
xGridKill(&npcs_grid);
17+
18+
gGridIterActive = NULL;
19+
zGridInitted = NULL;
20+
}

src/SB/Game/zNPCGoalVillager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ struct zNPCGoalBoySwim : zNPCGoalCommon
167167
}
168168
};
169169

170+
struct NPCSndProp
171+
{
172+
en_NPC_SOUND sndtype;
173+
int flg_snd;
174+
float tym_delayNext;
175+
};
176+
170177
xFactoryInst* GOALCreate_Villager(S32 who, RyzMemGrow* grow, void*);
171178

172179
#endif

src/SB/Game/zNPCSndTable.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
11
#include "zNPCSndTable.h"
2+
#include "zNPCGoalVillager.h"
3+
4+
#include "xString.h"
25

36
#include <types.h>
47

8+
static char* g_strz_sndgroup[26];
9+
static unsigned int g_hash_sndgroup[26];
10+
static float g_tmrz_sndplay[26];
11+
12+
NPCSndProp g_sndProps[];
13+
14+
void NPCS_Startup()
15+
{
16+
for (int i = 0; i < (int)(sizeof(g_strz_sndgroup) / sizeof(char*)); i++)
17+
{
18+
g_hash_sndgroup[i] = xStrHash(g_strz_sndgroup[i]);
19+
}
20+
}
21+
522
void NPCS_Shutdown()
623
{
724
}
25+
26+
int NPCS_SndOkToPlay(en_NPC_SOUND sndtype)
27+
{
28+
if (sndtype == NPC_STYP_BOGUS)
29+
{
30+
return 1;
31+
}
32+
if (sndtype == NPC_STYP_LISTEND)
33+
{
34+
return 0;
35+
}
36+
return g_tmrz_sndplay[sndtype] < 0.0f;
37+
}
38+
39+
void NPCS_SndTypePlayed(en_NPC_SOUND sndtype, float delayNext)
40+
{
41+
float tym = 2.0f;
42+
43+
switch (sndtype)
44+
{
45+
case NPC_STYP_TIKISTACK:
46+
tym = 0.15f;
47+
break;
48+
case NPC_STYP_TIKIEXPLODE:
49+
tym = 2.0f;
50+
break;
51+
default:
52+
tym = -1.0f;
53+
break;
54+
}
55+
56+
if (delayNext > 0.0f)
57+
{
58+
tym = delayNext;
59+
}
60+
61+
g_tmrz_sndplay[sndtype] = tym;
62+
}

0 commit comments

Comments
 (0)