Skip to content

Commit

Permalink
misc: remove noisy allocation logs
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jan 7, 2024
1 parent dc54832 commit 32bf8f4
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 71 deletions.
50 changes: 0 additions & 50 deletions src/qst.cpp
Expand Up @@ -84,7 +84,6 @@ extern comboclass *combo_class_buf;
extern guydata *guysbuf;
extern ZCHEATS zcheats;
extern char palnames[MAXLEVELS][17];
extern int32_t memrequested;
extern char *byte_conversion(int32_t number, int32_t format);
extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
string zScript;
Expand Down Expand Up @@ -1201,8 +1200,6 @@ bool reset_mapstyles(bool validate, miscQdata *Misc)

int32_t get_qst_buffers()
{
memrequested+=(sizeof(mapscr)*MAPSCRS);
Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
TheMaps.resize(MAPSCRS);
map_autolayers.resize(6);

Expand All @@ -1212,7 +1209,6 @@ int32_t get_qst_buffers()
//memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
Z_message("OK\n");

// Allocating space for all 65535 strings uses up 10.62MB...
// The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
// (Shoelace's "Hero of Dreams" uses 1415.)
// So let's be a bit generous and allow 4096 initially.
Expand All @@ -1222,8 +1218,6 @@ int32_t get_qst_buffers()
// this threshold. Possibly some bug related to `msglistcache` to being reset?
// See https://discord.com/channels/876899628556091432/992984989073416242
msg_strings_size = 8192;
memrequested+=(sizeof(MsgStr)*msg_strings_size);
Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));

MsgStrings = new MsgStr[msg_strings_size];

Expand All @@ -1232,41 +1226,24 @@ int32_t get_qst_buffers()
{
MsgStrings[q].clear();
}
Z_message("OK\n"); // Allocating string buffer...

memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));

if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
return 0;

Z_message("OK\n"); // Allocating door combo buffer...

memrequested+=(sizeof(dmap)*MAXDMAPS);
Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));

if((DMaps=new dmap[MAXDMAPS])==NULL)
return 0;

Z_message("OK\n"); // Allocating dmap buffer...

memrequested+=(sizeof(newcombo)*MAXCOMBOS);
Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));

combobuf.clear();
combobuf.resize(MAXCOMBOS);
Z_message("OK\n"); // Allocating combo buffer...

memrequested+=(psTOTAL255);
Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));

if((colordata=(byte*)malloc(psTOTAL255))==NULL)
return 0;

Z_message("OK\n"); // Allocating color data buffer...

memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));

free_newtilebuf();
if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
Expand All @@ -1276,70 +1253,43 @@ int32_t get_qst_buffers()
//Z_message("Performed memset on tiles\n");
clear_tiles(newtilebuf);
//Z_message("Performed clear_tiles()\n");
Z_message("OK\n"); // Allocating tile buffer...

if(is_editor())
{
memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));

if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
return 0;

memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
clear_tiles(grabtilebuf);
Z_message("OK\n"); // Allocating tile grab buffer...
}

memrequested+=(100000);
Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));

if((trashbuf=(byte*)malloc(100000))==NULL)
return 0;

Z_message("OK\n"); // Allocating trash buffer...

// Big, ugly band-aid here. Perhaps the most common cause of random crashes
// has been inadvertently accessing itemsbuf[-1]. All such crashes should be
// fixed by ensuring there's actually itemdata there.
// If you change this, be sure to update del_qst_buffers, too.

memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));

if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
return 0;

memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
itemsbuf++;
Z_message("OK\n"); // Allocating item buffer...

memrequested+=(sizeof(wpndata)*MAXWPNS);
Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));

if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
return 0;

memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
Z_message("OK\n"); // Allocating weapon buffer...

memrequested+=(sizeof(guydata)*MAXGUYS);
Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));

if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
return 0;

memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
Z_message("OK\n"); // Allocating guy buffer...

memrequested+=(sizeof(comboclass)*cMAX);
Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));

if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
return 0;

Z_message("OK\n"); // Allocating combo class buffer...

return 1;
}

Expand Down
1 change: 0 additions & 1 deletion src/zc/ffscript.cpp
Expand Up @@ -29251,7 +29251,6 @@ void do_allocatemem(const bool v, const bool local, ScriptType type, const uint3
a[j] = 0; //initialize array

// Keep track of which object created the array so we know which to deallocate
//Z_eventlog("Allocating array %d to script %s, %d\n", ptrval, script_types[type], UID);
arrayOwner[ptrval].reown(type, UID);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/zc/zelda.cpp
Expand Up @@ -330,7 +330,7 @@ int32_t hs_startx = 0, hs_starty = 0, hs_xdist = 0, hs_ydist = 0, clockclk = 0,
int32_t cheat_goto_dmap=0, cheat_goto_screen=0, currcset = 0, currspal6 = -1, currspal14 = -1;
int32_t gfc = 0, gfc2 = 0, pitx = 0, pity = 0, refill_what = 0, refill_why = 0, heart_beep_timer=0, new_enemy_tile_start=1580;
int32_t nets=1580, magicitem=-1,div_prot_item=-1, magiccastclk = 0, quakeclk=0, wavy=0, castx = 0, casty = 0, df_x = 0, df_y = 0, nl1_x = 0, nl1_y = 0, nl2_x = 0, nl2_y = 0;
int32_t magicdrainclk=0, conveyclk=3, memrequested=0;
int32_t magicdrainclk=0, conveyclk=3;
byte newconveyorclk = 0;
bool cheats_execute_goto=false, cheats_execute_light=false;
int32_t checkx = 0, checky = 0;
Expand Down Expand Up @@ -4496,7 +4496,6 @@ int main(int argc, char **argv)
Z_message("OK\n");

// allocate bitmap buffers
Z_message("Allocating bitmap buffers... ");
set_color_depth(8);
framebuf = create_bitmap_ex(8,256,224);
menu_bmp = create_bitmap_ex(8,640,480);
Expand Down Expand Up @@ -4539,7 +4538,6 @@ int main(int argc, char **argv)
set_clip_state(msg_portrait_display_buf, 1);
clear_bitmap(pricesdisplaybuf);
set_clip_state(pricesdisplaybuf, 1);
Z_message("OK\n");

Z_message("Initializing music... ");
zcmusic_init();
Expand Down
2 changes: 1 addition & 1 deletion src/zc/zelda.h
Expand Up @@ -358,7 +358,7 @@ extern int32_t DUkey, DDkey, DLkey, DRkey, DUbtn, DDbtn, DLbtn, DRbtn, ss_after,
extern int32_t hs_startx, hs_starty, hs_xdist, hs_ydist, clockclk, clock_zoras[eMAXGUYS];
extern int32_t swordhearts[4], currcset, currspal6, currspal14, gfc, gfc2, pitx, pity, refill_what, refill_why;
extern int32_t heart_beep_timer, new_enemy_tile_start, nets, magicitem, div_prot_item;
extern int32_t magiccastclk, castx, casty, quakeclk, wavy, df_x, df_y, nl1_x, nl1_y, nl2_x, nl2_y, magicdrainclk, conveyclk, memrequested;
extern int32_t magiccastclk, castx, casty, quakeclk, wavy, df_x, df_y, nl1_x, nl1_y, nl2_x, nl2_y, magicdrainclk, conveyclk;
extern byte newconveyorclk;

extern bool cheats_execute_goto, cheats_execute_light;
Expand Down
15 changes: 0 additions & 15 deletions src/zq/zquest.cpp
Expand Up @@ -626,7 +626,6 @@ int32_t LeechUpdateTiles = 0;
int32_t SnapshotFormat = 0;
byte SnapshotScale = 0;

int32_t memrequested = 0;
byte Color = 0;
extern int32_t jwin_pal[jcMAX];
int32_t gui_colorset=99;
Expand Down Expand Up @@ -25705,8 +25704,6 @@ bool no_subscreen()

static void allocate_crap()
{
memrequested+=(2048*5);
Z_message("Allocating file path buffers (%s)... ", byte_conversion2(2048*7,memrequested,-1,-1));
filepath=(char*)malloc(2048);
temppath=(char*)malloc(2048);
datapath=(char*)malloc(2048);
Expand All @@ -25720,10 +25717,7 @@ static void allocate_crap()
Z_error_fatal("Error: no memory for file paths!");
}

Z_message("OK\n"); // Allocating file path buffers...

memrequested+=sizeof(zctune)*MAXCUSTOMMIDIS_ZQ;
Z_message("Allocating tunes buffer (%s)... ", byte_conversion2(sizeof(zctune)*MAXCUSTOMMIDIS_ZQ,memrequested,-1,-1));
customtunes = (zctune*)malloc(sizeof(class zctune)*MAXCUSTOMMIDIS_ZQ);
memset(customtunes, 0, sizeof(class zctune)*MAXCUSTOMMIDIS_ZQ);

Expand Down Expand Up @@ -26044,23 +26038,15 @@ int32_t main(int32_t argc,char **argv)
Z_error_fatal("Error");
}

memrequested+=sizeof(newcombo)*MAXCOMBOS;
Z_message("Allocating combo undo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
undocombobuf.clear();
undocombobuf.resize(MAXCOMBOS);

Z_message("OK\n"); // Allocating combo undo buffer...

memrequested+=(NEWMAXTILES*sizeof(tiledata));
Z_message("Allocating new tile undo buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));

if((newundotilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
{
Z_error_fatal("Error: no memory for tile undo buffer!");
}

memset(newundotilebuf, 0, NEWMAXTILES*sizeof(tiledata));
Z_message("OK\n"); // Allocating new tile buffer...

Z_message("Resetting new tile buffer...");
newtilebuf = (tiledata*)malloc(NEWMAXTILES*sizeof(tiledata));
Expand All @@ -26070,7 +26056,6 @@ int32_t main(int32_t argc,char **argv)

Z_message("OK\n");


zc_srand(time(0));

Z_message("Initializing Allegro... ");
Expand Down
1 change: 0 additions & 1 deletion src/zq/zquest.h
Expand Up @@ -193,7 +193,6 @@ extern int32_t LeechUpdate;
extern int32_t LeechUpdateTiles;
extern int32_t SnapshotFormat;
extern byte SnapshotScale;
extern int32_t memrequested;
extern byte Color;

extern byte compile_tune;
Expand Down

0 comments on commit 32bf8f4

Please sign in to comment.