Skip to content

Commit

Permalink
Found better name for the memory allocation function
Browse files Browse the repository at this point in the history
  • Loading branch information
TokyoSU committed Oct 30, 2024
1 parent 6561842 commit 28d76bc
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion TSEditor/game/deathsld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static GAME_VECTOR* GetDeathSlidePrevPosition(ITEM_INFO* item) {
void InitialiseDeathSlide(short item_number)
{
auto* item = &items[item_number];
auto* prevPos = (GAME_VECTOR*)MALLOC_AllocateMemory(sizeof(GAME_VECTOR));
auto* prevPos = (GAME_VECTOR*)MEM_Allocate(sizeof(GAME_VECTOR));
item->data = prevPos;
prevPos->x = item->pos.x_pos;
prevPos->y = item->pos.y_pos;
Expand Down
4 changes: 2 additions & 2 deletions TSEditor/game/deltapak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3506,7 +3506,7 @@ void init_cutseq_actors(char* data, long resident)
resident_addr += sizeof(PACKNODE) * (pda_nodes + 1);
}
else
actor_pnodes[i] = (PACKNODE*)MALLOC_AllocateMemory(sizeof(PACKNODE) * (pda_nodes + 1));
actor_pnodes[i] = (PACKNODE*)MEM_Allocate(sizeof(PACKNODE) * (pda_nodes + 1));

if (!i)
{
Expand Down Expand Up @@ -3545,7 +3545,7 @@ void init_cutseq_actors(char* data, long resident)
resident_addr += sizeof(PACKNODE) * (pda_nodes + 1);
}
else
camera_pnodes = (PACKNODE*)MALLOC_AllocateMemory(sizeof(PACKNODE) * (pda_nodes + 1));
camera_pnodes = (PACKNODE*)MEM_Allocate(sizeof(PACKNODE) * (pda_nodes + 1));

InitPackNodes(nlheader, camera_pnodes, packed, pda_nodes + 1);
GLOBAL_playing_cutseq = 1;
Expand Down
2 changes: 1 addition & 1 deletion TSEditor/game/guardian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void InitialiseGuardian(short item_number)
short angle;

item = &items[item_number];
item->data = MALLOC_AllocateMemory(20);
item->data = MEM_Allocate(20);
aptr = (short*)item->data;

for (int i = 0; i < level_items; i++)
Expand Down
16 changes: 8 additions & 8 deletions TSEditor/game/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void InitialiseDoor(short item_number)
if (item->object_number >= LIFT_DOORS1 && item->object_number <= LIFT_DOORS2)
item->item_flags[0] = 4096;

door = (DOOR_DATA*)MALLOC_AllocateMemory(sizeof(DOOR_DATA));
door = (DOOR_DATA*)MEM_Allocate(sizeof(DOOR_DATA));
item->data = door;
door->Opened = 0;
door->dptr1 = 0;
Expand Down Expand Up @@ -583,7 +583,7 @@ void InitialiseLasers(short item_number)
short room_num;

item = &items[item_number];
item->data = (LASER_STRUCT*)MALLOC_AllocateMemory(sizeof(LASER_STRUCT));
item->data = (LASER_STRUCT*)MEM_Allocate(sizeof(LASER_STRUCT));
width = (item->trigger_flags & 0xFF) << 10;

if (!(item->trigger_flags & 1))
Expand Down Expand Up @@ -640,7 +640,7 @@ void InitialiseSteamLasers(short item_number)
short room_num;

item = &items[item_number];
item->data = (STEAMLASER_STRUCT*)MALLOC_AllocateMemory(sizeof(STEAMLASER_STRUCT));
item->data = (STEAMLASER_STRUCT*)MEM_Allocate(sizeof(STEAMLASER_STRUCT));
height = 1536;
width = 2048;
Xadd = (width / 2) - 512;
Expand Down Expand Up @@ -683,7 +683,7 @@ void InitialiseFloorLasers(short item_number)
long width, height;

item = &items[item_number];
item->data = (FLOORLASER_STRUCT*)MALLOC_AllocateMemory(sizeof(FLOORLASER_STRUCT));
item->data = (FLOORLASER_STRUCT*)MEM_Allocate(sizeof(FLOORLASER_STRUCT));
ls = (FLOORLASER_STRUCT*)item->data;

width = item->trigger_flags % 10;
Expand Down Expand Up @@ -1064,7 +1064,7 @@ void InitialiseAutogun(short item_number)

item = &items[item_number];
item->mesh_bits = 1024;
item->data = MALLOC_AllocateMemory(sizeof(CREATURE_INFO));
item->data = MEM_Allocate(sizeof(CREATURE_INFO));
}

void InitialiseKeyhole(short item_number)
Expand Down Expand Up @@ -1105,7 +1105,7 @@ void InitialisePortalDoor(short item_number)
PORTAL_STRUCT* portal;

item = &items[item_number];
portal = (PORTAL_STRUCT*)MALLOC_AllocateMemory(sizeof(PORTAL_STRUCT));
portal = (PORTAL_STRUCT*)MEM_Allocate(sizeof(PORTAL_STRUCT));
item->pos.x_pos -= 512;
item->data = portal;

Expand Down Expand Up @@ -1230,7 +1230,7 @@ void InitialiseGasCloud(short item_number)
return;
}

cloud = (GAS_CLOUD*)MALLOC_AllocateMemory(sizeof(GAS_CLOUD) * 8);
cloud = (GAS_CLOUD*)MEM_Allocate(sizeof(GAS_CLOUD) * 8);
item->data = cloud;
memset(clouds, NO_ITEM, sizeof(clouds));

Expand Down Expand Up @@ -1324,7 +1324,7 @@ void InitialiseAnimatingSlots(short item_number)

if (item->trigger_flags == 666 || item->trigger_flags == 667)
{
c = (CREATURE_INFO*)MALLOC_AllocateMemory(sizeof(CREATURE_INFO));
c = (CREATURE_INFO*)MEM_Allocate(sizeof(CREATURE_INFO));
item->data = c;
c->joint_rotation[0] = 0;
c->joint_rotation[1] = 0;
Expand Down
2 changes: 1 addition & 1 deletion TSEditor/game/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void InitialiseFXArray(long allocmem)
FX_INFO* fx;

if (allocmem)
effects = (FX_INFO*)MALLOC_AllocateMemory(sizeof(FX_INFO) * 24);
effects = (FX_INFO*)MEM_Allocate(sizeof(FX_INFO) * 24);

next_fx_active = NO_ITEM;
next_fx_free = 0;
Expand Down
4 changes: 2 additions & 2 deletions TSEditor/game/lot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ void InitialiseLOTarray(long allocmem)
CREATURE_INFO* creature;

if (allocmem)
baddie_slots = (CREATURE_INFO*)MALLOC_AllocateMemory(sizeof(CREATURE_INFO) * MAX_LOT);
baddie_slots = (CREATURE_INFO*)MEM_Allocate(sizeof(CREATURE_INFO) * MAX_LOT);

for (int i = 0; i < MAX_LOT; i++)
{
creature = &baddie_slots[i];
creature->item_num = NO_ITEM;

if (allocmem)
creature->LOT.node = (BOX_NODE*)MALLOC_AllocateMemory(sizeof(BOX_NODE) * num_boxes);
creature->LOT.node = (BOX_NODE*)MEM_Allocate(sizeof(BOX_NODE) * num_boxes);
}

slots_used = 0;
Expand Down
10 changes: 5 additions & 5 deletions TSEditor/game/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1912,13 +1912,13 @@ void InitialiseObjects()
objects[2 * (gfMips[lp] & 0xF) + ANIMATING1].object_mip = 64 * (gfMips[lp] & 0xF0);

if (objects[RAT].loaded)
Rats = (RAT_STRUCT*)MALLOC_AllocateMemory(832);
Rats = (RAT_STRUCT*)MEM_Allocate(832);

if (objects[BAT].loaded)
Bats = (BAT_STRUCT*)MALLOC_AllocateMemory(1920);
Bats = (BAT_STRUCT*)MEM_Allocate(1920);

if (objects[SPIDER].loaded)
Spiders = (SPIDER_STRUCT*)MALLOC_AllocateMemory(1664);
Spiders = (SPIDER_STRUCT*)MEM_Allocate(1664);
}

void GetCarriedItems()
Expand Down Expand Up @@ -2036,8 +2036,8 @@ void BuildOutsideTable()
char flipped[256];

max_slots = 0;
OutsideRoomOffsets = (short*)MALLOC_AllocateMemory(0x5B2);
OutsideRoomTable = (char*)MALLOC_AllocateMemory(0xB640);
OutsideRoomOffsets = (short*)MEM_Allocate(0x5B2);
OutsideRoomTable = (char*)MEM_Allocate(0xB640);
memset(OutsideRoomTable, 0xFF, 0xB640);
memset(flipped, 0, 255);

Expand Down
2 changes: 1 addition & 1 deletion TSEditor/specific/alexstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ char* aReadCutData(long n, FILE* file)
offset = *(long*)&tsv_buffer[n * 2 * sizeof(long)];
size = *(long*)&tsv_buffer[n * 2 * sizeof(long) + 4];
fseek(file, offset, SEEK_SET);
data = (char*)MALLOC_AllocateMemory(size);
data = (char*)MEM_Allocate(size);
fread(data, size, 1, file);
return data;
}
Expand Down
14 changes: 7 additions & 7 deletions TSEditor/specific/drawroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void ProcessMeshData(long num_meshes)

Log(__FUNCTION__ " %d", num_meshes);
num_level_meshes = num_meshes;
mesh_vtxbuf = (MESH_DATA**)MALLOC_AllocateMemory(4 * num_meshes);
mesh_vtxbuf = (MESH_DATA**)MEM_Allocate(4 * num_meshes);
mesh_base = (short*)malloc_ptr;
last_mesh_ptr = 0;
data = 0;
Expand All @@ -763,7 +763,7 @@ void ProcessMeshData(long num_meshes)
maxx = -20000.0F;
maxy = -20000.0F;
maxz = -20000.0F;
data = (MESH_DATA*)MALLOC_AllocateMemory(sizeof(MESH_DATA));
data = (MESH_DATA*)MEM_Allocate(sizeof(MESH_DATA));
memset(data, 0, sizeof(MESH_DATA));
meshes[i] = (short*)data;
mesh_vtxbuf[i] = data;
Expand All @@ -778,7 +778,7 @@ void ProcessMeshData(long num_meshes)
num = *mesh_ptr >> 8;

mesh_ptr++;
data->aVtx = (ACMESHVERTEX*)MALLOC_AllocateMemory(sizeof(ACMESHVERTEX) * data->nVerts);
data->aVtx = (ACMESHVERTEX*)MEM_Allocate(sizeof(ACMESHVERTEX) * data->nVerts);

if (data->nVerts)
{
Expand Down Expand Up @@ -824,7 +824,7 @@ void ProcessMeshData(long num_meshes)
if (data->nNorms <= 0)
{
data->Normals = 0;
data->prelight = (long*)MALLOC_AllocateMemory(4 * data->nVerts);
data->prelight = (long*)MEM_Allocate(4 * data->nVerts);

for (int j = 0; j < data->nVerts; j++)
{
Expand All @@ -837,7 +837,7 @@ void ProcessMeshData(long num_meshes)
}
else
{
data->Normals = (D3DVECTOR*)MALLOC_AllocateMemory(sizeof(D3DVECTOR) * data->nNorms);
data->Normals = (D3DVECTOR*)MEM_Allocate(sizeof(D3DVECTOR) * data->nNorms);

for (int j = 0; j < data->nVerts; j++)
{
Expand All @@ -860,7 +860,7 @@ void ProcessMeshData(long num_meshes)

if (data->ngt4)
{
data->gt4 = (short*)MALLOC_AllocateMemory(12 * data->ngt4);
data->gt4 = (short*)MEM_Allocate(12 * data->ngt4);
memcpy(data->gt4, mesh_ptr, 12 * data->ngt4);
mesh_ptr += 6 * data->ngt4;
gtx = data->gt4 + 5;
Expand All @@ -879,7 +879,7 @@ void ProcessMeshData(long num_meshes)

if (data->ngt3)
{
data->gt3 = (short*)MALLOC_AllocateMemory(10 * data->ngt3);
data->gt3 = (short*)MEM_Allocate(10 * data->ngt3);
memcpy(data->gt3, mesh_ptr, 10 * data->ngt3);

if (hand)
Expand Down
Loading

0 comments on commit 28d76bc

Please sign in to comment.