mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed some memory leaks
This commit is contained in:
parent
30e78ec74a
commit
8ff7c94ac2
|
@ -24,6 +24,7 @@ static SNAPBUILD builder;
|
|||
|
||||
static int64 game_start_time;
|
||||
static int current_tick = 0;
|
||||
static int run_server = 1;
|
||||
|
||||
static int browseinfo_gametype = -1;
|
||||
static int browseinfo_progression = -1;
|
||||
|
@ -31,6 +32,8 @@ static int browseinfo_progression = -1;
|
|||
static int64 lastheartbeat;
|
||||
/*static NETADDR4 master_server;*/
|
||||
|
||||
|
||||
|
||||
static char current_map[64];
|
||||
static int current_map_crc;
|
||||
static unsigned char *current_map_data = 0;
|
||||
|
@ -949,7 +952,7 @@ static int server_run()
|
|||
if(config.debug)
|
||||
dbg_msg("server", "baseline memory usage %dk", mem_allocated()/1024);
|
||||
|
||||
while(1)
|
||||
while(run_server)
|
||||
{
|
||||
static PERFORMACE_INFO rootscope = {"root", 0};
|
||||
int64 t = time_get();
|
||||
|
@ -1087,6 +1090,8 @@ static int server_run()
|
|||
mods_shutdown();
|
||||
map_unload();
|
||||
|
||||
if(current_map_data)
|
||||
mem_free(current_map_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1111,10 +1116,17 @@ static void con_status(void *result, void *user_data)
|
|||
}
|
||||
}
|
||||
|
||||
static void con_shutdown(void *result, void *user_data)
|
||||
{
|
||||
run_server = 0;
|
||||
/*server_kick(console_arg_int(result, 0), "kicked by console");*/
|
||||
}
|
||||
|
||||
static void server_register_commands()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("kick", "i", con_kick, 0);
|
||||
MACRO_REGISTER_COMMAND("status", "", con_status, 0);
|
||||
MACRO_REGISTER_COMMAND("shutdown", "", con_shutdown, 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
world_core core;
|
||||
|
||||
game_world();
|
||||
~game_world();
|
||||
int find_entities(vec2 pos, float radius, entity **ents, int max);
|
||||
int find_entities(vec2 pos, float radius, entity **ents, int max, const int* types, int maxtypes);
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@ entity::entity(int objtype)
|
|||
|
||||
entity::~entity()
|
||||
{
|
||||
world->remove_entity(this);
|
||||
snap_free_id(id);
|
||||
}
|
||||
|
||||
|
@ -196,6 +197,13 @@ game_world::game_world()
|
|||
first_entity_types[i] = 0;
|
||||
}
|
||||
|
||||
game_world::~game_world()
|
||||
{
|
||||
// delete all entities
|
||||
while(first_entity)
|
||||
delete first_entity;
|
||||
}
|
||||
|
||||
int game_world::find_entities(vec2 pos, float radius, entity **ents, int max)
|
||||
{
|
||||
int num = 0;
|
||||
|
|
Loading…
Reference in a new issue