diff --git a/src/ai.c b/src/ai.c index bed3140..0c7362c 100644 --- a/src/ai.c +++ b/src/ai.c @@ -138,14 +138,17 @@ static int ai_broadcast(lua_State* L); // broadcast(string) static int ai_rng(lua_State* L); // rng(number, number) static const luaL_Reg ai_methods[] = { + // Tasks. { "pushtask", ai_pushtask }, { "poptask", ai_poptask }, { "taskname", ai_taskname }, + // Sanity checks. { "exists", ai_exists }, { "ismaxvel", ai_ismaxvel }, { "isstopped", ai_isstopped }, { "isenemy", ai_isenemy }, { "isally", ai_isally }, + // Get's. { "incombat", ai_incombat }, { "target", ai_gettarget }, { "targetid", ai_gettargetid }, @@ -158,20 +161,24 @@ static const luaL_Reg ai_methods[] = { { "minbrakedist", ai_minbrakedist }, { "nearestplanet", ai_getnearestplanet }, { "rndplanet", ai_getrndplanet }, + // Movement. { "accel", ai_accel }, { "turn", ai_turn }, { "face", ai_face }, { "brake", ai_brake }, { "stop", ai_stop }, { "hyperspace", ai_hyperspace }, + // Combat. { "combat", ai_combat }, { "settarget", ai_settarget }, { "secondary", ai_secondary }, { "shoot", ai_shoot }, { "getenemy", ai_getenemy }, { "hostile", ai_hostile }, + // Timers. { "settime", ai_settimer }, { "timeup", ai_timeup }, + // Messages. { "comm", ai_comm }, { "broadcast", ai_broadcast }, { "rnd", ai_rng }, @@ -223,8 +230,13 @@ static int ai_loadProfile(char* filename) { uint32_t bufsize = 0; profiles = realloc(profiles, sizeof(AI_Profile)*(++nprofiles)); - profiles[nprofiles-1].name = strndup(filename+strlen(AI_PREFIX), - strlen(filename)-strlen(AI_PREFIX)-strlen(AI_SUFFIX)); + + profiles[nprofiles-1].name = + malloc(sizeof(char)*(strlen(filename)-strlen(AI_PREFIX)-strlen(AI_SUFFIX))+1); + + snprintf(profiles[nprofiles-1].name, + strlen(filename)-strlen(AI_PREFIX)-strlen(AI_SUFFIX)+1, + "%s", filename+strlen(AI_PREFIX)); profiles[nprofiles-1].L = luaL_newstate(); diff --git a/src/opengl.c b/src/opengl.c index 21e73c6..1ee2cd7 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -111,7 +111,7 @@ static uint8_t* SDL_MapTrans(SDL_Surface* s) { // Allocate memory for just enough bits to hold all the data we need. int size = s->w*s->h/8 + ((s->w*s->h%8)?1:0); uint8_t* t = malloc(size); - bzero(t, size); // *must* be set to zero. + memset(t, 0, size); // *must* be set to zero. if(t == NULL) { WARN("Out of memeory");