Cleanup a few global variables
This commit is contained in:
parent
6fa2be3ce5
commit
41b9c38411
@ -214,12 +214,9 @@ static void _app_LevelCommand(App *app, char *cmd) {
|
||||
}
|
||||
|
||||
|
||||
// Defined in render_bundle_file.c
|
||||
extern char linebuf[512];
|
||||
|
||||
void _app_SwitchLevel(App *app) {
|
||||
if (app->switch_level == NULL) {
|
||||
WARN("called when switch_level is NULL", 0);
|
||||
WARN("called when switch_level is NULL");
|
||||
return;
|
||||
}
|
||||
INFO("Switching level to %s", app->switch_level);
|
||||
@ -238,6 +235,8 @@ void _app_SwitchLevel(App *app) {
|
||||
app->camera->target = NULL;
|
||||
|
||||
// Read every line
|
||||
char linebuf[512];
|
||||
memset(linebuf, 0, sizeof(linebuf));
|
||||
while (!feof(f) && fgets(linebuf, sizeof(linebuf), f)) {
|
||||
while (linebuf[strlen(linebuf) - 1] == '\n')
|
||||
linebuf[strlen(linebuf) - 1] = '\0';
|
||||
|
@ -86,7 +86,7 @@ static inline void _physics_AdvanceEntity(System_Physics *sys, Entity *e, Durati
|
||||
}
|
||||
|
||||
|
||||
static double gravity = 2000;
|
||||
static const double gravity = 2000;
|
||||
|
||||
void physics_Advance(System_Physics *sys, Duration deltaTime) {
|
||||
for (tree_Node *i = tree_FirstNode(sys->pos);
|
||||
|
8
player.c
8
player.c
@ -56,9 +56,9 @@ void player_DeleteEntity(System_Player *sys, uintptr_t id) {
|
||||
}
|
||||
|
||||
|
||||
static double walkSpeed = 300.0, jumpSpeed = 800.0, dashSpeed = 1500.0;
|
||||
static int airjumpCount = 1, airdashCount = 1, airjumpParticleCount = 10;
|
||||
static Duration dashLength = {.microseconds = 150000}, dashCooldown = {.microseconds = 400000};
|
||||
static const double walkSpeed = 300.0, jumpSpeed = 800.0, dashSpeed = 1500.0;
|
||||
static const int airjumpCount = 1, airdashCount = 1, airjumpParticleCount = 10;
|
||||
static const Duration dashLength = {.microseconds = 150000}, dashCooldown = {.microseconds = 400000};
|
||||
|
||||
|
||||
void player_Advance(System_Player *sys, Duration deltaTime) {
|
||||
@ -179,7 +179,7 @@ void player_Advance(System_Player *sys, Duration deltaTime) {
|
||||
}
|
||||
|
||||
|
||||
static int harmed_particle_count = 20;
|
||||
static const int harmed_particle_count = 20;
|
||||
|
||||
void player_HazardHarm(System_Player *sys) {
|
||||
if (!sys->player)
|
||||
|
@ -25,7 +25,7 @@ static void _render_BundleCommand(char *cmd) {
|
||||
if (CMD("BUNDLE")) {
|
||||
// Start a bundle
|
||||
if (_tmpb != NULL) {
|
||||
WARN("_tmpb!=0, you forgot to use ENDBUNDLE for the last bundle, discarding", 0);
|
||||
WARN("_tmpb!=0, you forgot to use ENDBUNDLE for the last bundle, discarding");
|
||||
free(_tmpb);
|
||||
}
|
||||
_tmpb = render_NewBundle(strtok(NULL, " "));
|
||||
@ -38,13 +38,13 @@ static void _render_BundleCommand(char *cmd) {
|
||||
vector_Push(render_Bundles, &_tmpb);
|
||||
_tmpb = NULL;
|
||||
} else
|
||||
WARN("_tmpb==0, ENDBUNDLE without BUNDLE first", 0);
|
||||
WARN("_tmpb==0, ENDBUNDLE without BUNDLE first");
|
||||
|
||||
|
||||
} else if (CMD("PRIM")) {
|
||||
// start a primitive
|
||||
if (_tmpp != NULL) {
|
||||
WARN("_tmpp!=0, you forgot to ENDPRIM for the last primitive, discarding", 0);
|
||||
WARN("_tmpp!=0, you forgot to ENDPRIM for the last primitive, discarding");
|
||||
if (_tmpp->points)
|
||||
vector_Destroy(_tmpp->points);
|
||||
free(_tmpp);
|
||||
@ -82,7 +82,7 @@ static void _render_BundleCommand(char *cmd) {
|
||||
Vec2 v = vec2(x, y);
|
||||
vector_Push(_tmpp->points, &v);
|
||||
} else
|
||||
WARN("P without PRIM first", 0);
|
||||
WARN("P without PRIM first");
|
||||
} else if (CMD("FG")) {
|
||||
// Set Foreground color
|
||||
if (_tmpp) {
|
||||
@ -91,7 +91,7 @@ static void _render_BundleCommand(char *cmd) {
|
||||
int b = atoi(strtok(NULL, " "));
|
||||
_tmpp->mode.fg = RGB(r, g, b);
|
||||
} else
|
||||
WARN("FG without PRIM first", 0);
|
||||
WARN("FG without PRIM first");
|
||||
} else if (CMD("BG")) {
|
||||
// Set Background color
|
||||
if (_tmpp) {
|
||||
@ -100,7 +100,7 @@ static void _render_BundleCommand(char *cmd) {
|
||||
int b = atoi(strtok(NULL, " "));
|
||||
_tmpp->mode.bg = RGB(r, g, b);
|
||||
} else
|
||||
WARN("BG without PRIM first", 0);
|
||||
WARN("BG without PRIM first");
|
||||
} else {
|
||||
WARN("unknown command %s", cmd);
|
||||
}
|
||||
@ -108,8 +108,6 @@ static void _render_BundleCommand(char *cmd) {
|
||||
}
|
||||
|
||||
|
||||
char linebuf[512];
|
||||
|
||||
void render_LoadBundle(const char *filename) {
|
||||
if (!render_Bundles)
|
||||
render_Bundles = vector_Create(sizeof(render_Bundle *));
|
||||
@ -120,6 +118,7 @@ void render_LoadBundle(const char *filename) {
|
||||
return;
|
||||
}
|
||||
|
||||
char linebuf[512];
|
||||
while (!feof(f) && fgets(linebuf, sizeof(linebuf), f)) {
|
||||
while (linebuf[strlen(linebuf) - 1] == '\n')
|
||||
linebuf[strlen(linebuf) - 1] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user