fix compiler warnings

This commit is contained in:
John Alanbrook 2023-04-29 01:55:24 +00:00
parent 8ca1ab4384
commit 0bf7d419e0
14 changed files with 29 additions and 24 deletions

View file

@ -66,13 +66,13 @@ includeflag != find source -type d -name include
includeflag += $(engincs) source/engine/thirdparty/Nuklear
includeflag := $(addprefix -I, $(includeflag))
WARNING_FLAGS = -Wall# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
WARNING_FLAGS = -Wall -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
SEM = 0.0.1
COM != git rev-parse --short HEAD
VER = $(SEM)-$(COM)
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -march=native -std=c99 -c $< -o $@
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -I. -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -march=native -std=c99 -c $< -o $@
LIBPATH = -L$(BIN)

View file

@ -7,12 +7,13 @@
#include "debug.h"
#include "debugdraw.h"
#include "gameobject.h"
#include <math.h>
#include <chipmunk/chipmunk_unsafe.h>
#include "stb_ds.h"
#include <assert.h>
#include "2dphysics.h"
#include "tinyspline.h"
#include "script.h"
@ -459,7 +460,6 @@ void phys2d_applypoly(struct phys2d_poly *poly)
void phys2d_dbgdrawpoly(struct phys2d_poly *poly)
{
float *color = shape_color(poly->shape.shape);
int n = arrlen(poly->points);
if (arrlen(poly->points) >= 3) {
int n = cpPolyShapeGetCount(poly->shape.shape);
@ -686,7 +686,6 @@ static cpBool handle_collision(cpArbiter *arb, int type)
struct phys2d_shape *pshape2 = cpShapeGetUserData(shape2);
cpVect norm1 = cpArbiterGetNormal(arb);
cpVect vel1 = cpArbiterGetSurfaceVelocity(arb);
switch (type) {
case CTYPE_BEGIN:

View file

@ -8,6 +8,8 @@
#include <unistd.h>
#include <stdio.h>
#include "script.h"
int logLevel = 1;
/* Four levels of log:
@ -25,8 +27,8 @@ FILE *logfile = NULL;
#define CONSOLE_BUF 1024*1024*5/* 5MB */
char lastlog[ERROR_BUFFER] = {'\0'};
char consolelog[CONSOLE_BUF] = {'\0'};
char lastlog[ERROR_BUFFER+1] = {'\0'};
char consolelog[CONSOLE_BUF+1] = {'\0'};
void mYughLog(int category, int priority, int line, const char *file, const char *message, ...)
{

View file

@ -162,7 +162,6 @@ struct sFont *MakeFont(const char *fontfile, int height)
}
static int curchar = 0;
static float *buffdraw;
void draw_char_box(struct Character c, float cursor[2], float scale, float color[3])
{
@ -281,7 +280,6 @@ int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3]
curchar = 0;
float *usecolor = color;
float caretcolor[3] = {0.4,0.98,0.75};
while (*line != '\0') {

View file

@ -40,9 +40,9 @@ int body2id(cpBody *body)
cpBody *id2body(int id)
{
struct gameobject *go;
struct gameobject *go = id2go(id);
if (go = id2go(id))
if (go)
return go->body;
return NULL;
@ -88,7 +88,7 @@ void gameobject_set_sensor(int id, int sensor)
int go2id(struct gameobject *go)
{
id_from_gameobject(go);
return id_from_gameobject(go);
}
void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go)

View file

@ -47,6 +47,8 @@ const char *gamepad2str(int btn)
case GLFW_GAMEPAD_BUTTON_LEFT_THUMB: return "lthumb";
case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB: return "rthumb";
}
return "NOBTN";
}
void register_pawn(struct callee c)
@ -196,7 +198,7 @@ void input_init()
glfwSetJoystickCallback(joystick_cb);
nukechar = glfwSetCharCallback(mainwin->window, char_cb);
const char *paddb = slurp_text("data/gamecontrollerdb.txt");
char *paddb = slurp_text("data/gamecontrollerdb.txt");
glfwUpdateGamepadMappings(paddb);
free(paddb);
@ -229,8 +231,9 @@ void call_input_signal(char *signal) {
JS_FreeValue(js, s);
}
const char *keyname_extd(int key, int scancode) {
char keybuf[50];
const char *keyname_extd(int key, int scancode) {
const char *kkey = NULL;
if (key > 289 && key < 302) {
@ -372,6 +375,8 @@ const char *axis2str(int axis)
case GLFW_GAMEPAD_AXIS_LEFT_TRIGGER: return "ltrigger";
case GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER: return "rtrigger";
}
return "NOAXIS";
}
/* This is called once every frame - or more if we want it more! */
@ -394,7 +399,6 @@ void input_poll(double wait)
JSValue argv[3];
argv[0] = num_cache[joysticks[i].id];
char inputstr[50];
for (int b = 0; b < 15; b++) {
argv[1] = jsgamepadstr[b];

View file

@ -60,7 +60,6 @@ struct sprite *tsprite = NULL;
static unsigned int projUBO;
static unsigned int resUBO;
void debug_draw_phys(int draw) {
debugDrawPhysics = draw;

View file

@ -31,7 +31,7 @@ static const char *cur_ext = NULL;
struct dirent *c_dirent = NULL;
struct vec *c_vec = NULL;
char pathbuf[MAXPATH];
char pathbuf[MAXPATH+1];
void resources_init()
{

View file

@ -99,7 +99,11 @@ int js_print_exception(JSValue v)
JS_FreeCString(js, msg);
JS_FreeCString(js, stack);
}
return 1;
}
return 0;
}
int script_dofile(const char *file) {
@ -139,6 +143,7 @@ JSValue js_callee_exec(struct callee *c, int argc, JSValue *argv)
JSValue ret = JS_Call(js, c->fn, c->obj, argc, argv);
js_print_exception(ret);
JS_FreeValue(js, ret);
return JS_NULL;
}
void call_callee(struct callee *c) {

View file

@ -15,6 +15,7 @@ struct callee {
extern struct callee stacktrace_callee;
extern JSValue num_cache[100];
void js_stacktrace();
void script_startup();
void script_init();
void script_run(const char *script);

View file

@ -30,8 +30,6 @@ int make_sprite(int go)
.layer = 0,
.enabled = 1 };
int ret;
if (first<0) {
arrput(sprites, sprite);
arrlast(sprites).id = arrlen(sprites)-1;

View file

@ -63,7 +63,6 @@ struct Texture *texture_pullfromfile(const char *path)
glGenTextures(1, &tex->id);
glBindTexture(GL_TEXTURE_2D, tex->id);
GLenum fmt;
switch (n) {
@ -84,7 +83,7 @@ struct Texture *texture_pullfromfile(const char *path)
break;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->width, tex->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->width, tex->height, 0, fmt, GL_UNSIGNED_BYTE, data);
if (tex->opts.mips)
glGenerateMipmap(GL_TEXTURE_2D);

View file

@ -1,8 +1,7 @@
#include "transform.h"
#include <string.h>
struct mTransform MakeTransform(mfloat_t pos[3], mfloat_t rotation[4],
float scale)
struct mTransform MakeTransform(mfloat_t pos[3], mfloat_t rotation[4], float scale)
{
struct mTransform newT;
memcpy(newT.position, pos, sizeof(*pos));

View file

@ -47,6 +47,7 @@ void window_iconify_callback(GLFWwindow *w, int iconified)
void window_focus_callback(GLFWwindow *w, int focused)
{
struct window *win = winfind(w);
win->mouseFocus = focused;
}
void window_maximize_callback(GLFWwindow *w, int maximized)