libzoom: Fixed some warnings with -Wall

This commit is contained in:
neoraider 2007-10-31 23:27:03 +00:00
parent 0d161e31bb
commit 68ba1f6942
4 changed files with 73 additions and 73 deletions

4
init.c
View file

@ -18,8 +18,8 @@ extern PLAYER player;
int InitGame() { int InitGame() {
LIGHT light = {LIGHT_POINT, {15.0, 15.0, 15.0}, {0.0, 0.0, 0.0}}; LIGHT light = {LIGHT_POINT, {{15.0, 15.0, 15.0}}, {{0.0, 0.0, 0.0}}};
COLOR ambient = {0.1, 0.1, 0.1}; COLOR ambient = {{0.1, 0.1, 0.1}};
glViewport(0, 0, 640, 480); glViewport(0, 0, 640, 480);

122
level.c
View file

@ -37,18 +37,18 @@ static void LoadTriangles(xmlNodePtr node, LEVEL *level, WALL* walls, int nWalls
for(; node != NULL; node = node->next) { for(; node != NULL; node = node->next) {
if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, "triangle")) continue; if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, (xmlChar*)"triangle")) continue;
walls[i].visible = 1; walls[i].visible = 1;
data = xmlGetProp(node, "visible"); data = xmlGetProp(node, (xmlChar*)"visible");
if(data) { if(data) {
if(!xmlStrcmp(data, "false")) walls[i].visible = 0; if(!xmlStrcmp(data, (xmlChar*)"false")) walls[i].visible = 0;
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node, "texture"); data = xmlGetProp(node, (xmlChar*)"texture");
if(data) { if(data) {
tex.name = data; tex.name = (char*)data;
texp = bsearch(&tex, level->textures, level->nTextures, sizeof(TEXTURE), SortTextures); texp = bsearch(&tex, level->textures, level->nTextures, sizeof(TEXTURE), SortTextures);
if(texp) walls[i].texture = texp->id; if(texp) walls[i].texture = texp->id;
@ -60,60 +60,60 @@ static void LoadTriangles(xmlNodePtr node, LEVEL *level, WALL* walls, int nWalls
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type != XML_ELEMENT_NODE) continue; if(node2->type != XML_ELEMENT_NODE) continue;
if(!xmlStrcmp(node2->name, "vertex")) { if(!xmlStrcmp(node2->name, (xmlChar*)"vertex")) {
if(++j > 2) break; if(++j > 2) break;
data = xmlGetProp(node2, "x"); data = xmlGetProp(node2, (xmlChar*)"x");
if(data) { if(data) {
walls[i].vertices[j].x = atof(data); walls[i].vertices[j].x = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "y"); data = xmlGetProp(node2, (xmlChar*)"y");
if(data) { if(data) {
walls[i].vertices[j].y = atof(data); walls[i].vertices[j].y = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "z"); data = xmlGetProp(node2, (xmlChar*)"z");
if(data) { if(data) {
walls[i].vertices[j].z = atof(data); walls[i].vertices[j].z = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
} }
else if(!xmlStrcmp(node2->name, "normal")) { else if(!xmlStrcmp(node2->name, (xmlChar*)"normal")) {
if(j < 0) continue; if(j < 0) continue;
data = xmlGetProp(node2, "x"); data = xmlGetProp(node2, (xmlChar*)"x");
if(data) { if(data) {
walls[i].normals[j].x = atof(data); walls[i].normals[j].x = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "y"); data = xmlGetProp(node2, (xmlChar*)"y");
if(data) { if(data) {
walls[i].normals[j].y = atof(data); walls[i].normals[j].y = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "z"); data = xmlGetProp(node2, (xmlChar*)"z");
if(data) { if(data) {
walls[i].normals[j].z = atof(data); walls[i].normals[j].z = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
} }
else if(!xmlStrcmp(node2->name, "texcoords")) { else if(!xmlStrcmp(node2->name, (xmlChar*)"texcoords")) {
if(j < 0) continue; if(j < 0) continue;
data = xmlGetProp(node2, "s"); data = xmlGetProp(node2, (xmlChar*)"s");
if(data) { if(data) {
walls[i].texcoords[j].s = atof(data); walls[i].texcoords[j].s = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "t"); data = xmlGetProp(node2, (xmlChar*)"t");
if(data) { if(data) {
walls[i].texcoords[j].t = atof(data); walls[i].texcoords[j].t = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
} }
@ -142,10 +142,10 @@ LEVEL *LoadLevel(char *filename) {
xmlDocPtr doc; xmlDocPtr doc;
xmlDtdPtr dtd; xmlDtdPtr dtd;
xmlValidCtxtPtr validCtxt; xmlValidCtxtPtr validCtxt;
xmlNodePtr root, node, node2, node3, rooms = NULL, gates = NULL; xmlNodePtr root, node, node2, rooms = NULL, gates = NULL;
xmlChar *data; xmlChar *data;
char *name; char *name;
int i, j; int i;
ROOM room, *roomp; ROOM room, *roomp;
@ -160,7 +160,7 @@ LEVEL *LoadLevel(char *filename) {
if(!doc) if(!doc)
return NULL; return NULL;
dtd = xmlParseDTD("-//libzoom//DTD level 0.1//EN", "levels/level.dtd"); dtd = xmlParseDTD((xmlChar*)"-//libzoom//DTD level 0.1//EN", (xmlChar*)"levels/level.dtd");
if(!dtd) { if(!dtd) {
xmlFreeDoc(doc); xmlFreeDoc(doc);
@ -189,7 +189,7 @@ LEVEL *LoadLevel(char *filename) {
xmlFreeDtd(dtd); xmlFreeDtd(dtd);
root = xmlDocGetRootElement(doc); root = xmlDocGetRootElement(doc);
if(!root || xmlStrcmp(root->name, "level")) { if(!root || xmlStrcmp(root->name, (xmlChar*)"level")) {
xmlFreeDoc(doc); xmlFreeDoc(doc);
xmlCleanupParser(); xmlCleanupParser();
return NULL; return NULL;
@ -202,51 +202,51 @@ LEVEL *LoadLevel(char *filename) {
for(node = root->children; node != NULL; node = node->next) { for(node = root->children; node != NULL; node = node->next) {
if(node->type != XML_ELEMENT_NODE) continue; if(node->type != XML_ELEMENT_NODE) continue;
if(!xmlStrcmp(node->name, "info")) { if(!xmlStrcmp(node->name, (xmlChar*)"info")) {
level->info = calloc(1, sizeof(LEVELINFO)); level->info = calloc(1, sizeof(LEVELINFO));
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type != XML_ELEMENT_NODE) continue; if(node2->type != XML_ELEMENT_NODE) continue;
if(!xmlStrcmp(node2->name, "name")) { if(!xmlStrcmp(node2->name, (xmlChar*)"name")) {
if(level->info->name != NULL) continue; if(level->info->name != NULL) continue;
data = xmlNodeGetContent(node2); data = xmlNodeGetContent(node2);
level->info->name = strdup(data); level->info->name = strdup((char*)data);
xmlFree(data); xmlFree(data);
} }
else if(!xmlStrcmp(node2->name, "desc")) { else if(!xmlStrcmp(node2->name, (xmlChar*)"desc")) {
if(level->info->desc != NULL) continue; if(level->info->desc != NULL) continue;
data = xmlNodeGetContent(node2); data = xmlNodeGetContent(node2);
level->info->desc = strdup(data); level->info->desc = strdup((char*)data);
xmlFree(data); xmlFree(data);
} }
else if(!xmlStrcmp(node2->name, "start")) { else if(!xmlStrcmp(node2->name, (xmlChar*)"start")) {
data = xmlGetProp(node2, "x"); data = xmlGetProp(node2, (xmlChar*)"x");
if(data) level->info->start.x = atof(data); if(data) level->info->start.x = atof((char*)data);
xmlFree(data); xmlFree(data);
data = xmlGetProp(node2, "y"); data = xmlGetProp(node2, (xmlChar*)"y");
if(data) level->info->start.y = atof(data); if(data) level->info->start.y = atof((char*)data);
xmlFree(data); xmlFree(data);
data = xmlGetProp(node2, "z"); data = xmlGetProp(node2, (xmlChar*)"z");
if(data) level->info->start.z = atof(data); if(data) level->info->start.z = atof((char*)data);
xmlFree(data); xmlFree(data);
} }
} }
} }
else if(!xmlStrcmp(node->name, "rooms")) { else if(!xmlStrcmp(node->name, (xmlChar*)"rooms")) {
if(rooms != NULL) continue; if(rooms != NULL) continue;
rooms = node; rooms = node;
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "room")) level->nRooms++; if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, (xmlChar*)"room")) level->nRooms++;
} }
} }
else if(!xmlStrcmp(node->name, "gates")) { else if(!xmlStrcmp(node->name, (xmlChar*)"gates")) {
if(gates != NULL) continue; if(gates != NULL) continue;
gates = node; gates = node;
@ -254,32 +254,32 @@ LEVEL *LoadLevel(char *filename) {
node2 = node->children; node2 = node->children;
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "gate")) level->nGates++; if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, (xmlChar*)"gate")) level->nGates++;
} }
} }
else if(!xmlStrcmp(node->name, "textures")) { else if(!xmlStrcmp(node->name, (xmlChar*)"textures")) {
if(level->textures != NULL) continue; if(level->textures != NULL) continue;
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "texture")) level->nTextures++; if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, (xmlChar*)"texture")) level->nTextures++;
} }
level->textures = calloc(level->nTextures, sizeof(TEXTURE)); level->textures = calloc(level->nTextures, sizeof(TEXTURE));
i = 0; i = 0;
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type != XML_ELEMENT_NODE || xmlStrcmp(node2->name, "texture")) continue; if(node2->type != XML_ELEMENT_NODE || xmlStrcmp(node2->name, (xmlChar*)"texture")) continue;
data = xmlGetProp(node2, "name"); data = xmlGetProp(node2, (xmlChar*)"name");
if(data) { if(data) {
level->textures[i].id = LoadTexture(data); level->textures[i].id = LoadTexture((char*)data);
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "id"); data = xmlGetProp(node2, (xmlChar*)"id");
if(data) { if(data) {
level->textures[i].name = strdup(data); level->textures[i].name = strdup((char*)data);
xmlFree(data); xmlFree(data);
} }
@ -295,17 +295,17 @@ LEVEL *LoadLevel(char *filename) {
i = 0; i = 0;
for(node = rooms->children; node != NULL; node = node->next) { for(node = rooms->children; node != NULL; node = node->next) {
if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, "room")) continue; if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, (xmlChar*)"room")) continue;
data = xmlGetProp(node, "id"); data = xmlGetProp(node, (xmlChar*)"id");
if(data) { if(data) {
level->rooms[i].id = strdup(data); level->rooms[i].id = strdup((char*)data);
xmlFree(data); xmlFree(data);
} }
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "triangle")) level->rooms[i].nWalls++; if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, (xmlChar*)"triangle")) level->rooms[i].nWalls++;
} }
level->rooms[i].walls = calloc(level->rooms[i].nWalls, sizeof(WALL)); level->rooms[i].walls = calloc(level->rooms[i].nWalls, sizeof(WALL));
@ -321,11 +321,11 @@ LEVEL *LoadLevel(char *filename) {
i = 0; i = 0;
for(node = gates->children; node != NULL; node = node->next) { for(node = gates->children; node != NULL; node = node->next) {
if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, "gate")) continue; if(node->type != XML_ELEMENT_NODE || xmlStrcmp(node->name, (xmlChar*)"gate")) continue;
data = xmlGetProp(node2, "room1"); data = xmlGetProp(node, (xmlChar*)"room1");
if(data) { if(data) {
room.id = data; room.id = (char*)data;
roomp = bsearch(&room, level->rooms, level->nRooms, sizeof(ROOM), SortRooms); roomp = bsearch(&room, level->rooms, level->nRooms, sizeof(ROOM), SortRooms);
if(roomp) level->gates[i].room1 = roomp; if(roomp) level->gates[i].room1 = roomp;
@ -333,9 +333,9 @@ LEVEL *LoadLevel(char *filename) {
xmlFree(data); xmlFree(data);
} }
data = xmlGetProp(node2, "room2"); data = xmlGetProp(node, (xmlChar*)"room2");
if(data) { if(data) {
room.id = data; room.id = (char*)data;
roomp = bsearch(&room, level->rooms, level->nRooms, sizeof(ROOM), SortRooms); roomp = bsearch(&room, level->rooms, level->nRooms, sizeof(ROOM), SortRooms);
if(roomp) level->gates[i].room2 = roomp; if(roomp) level->gates[i].room2 = roomp;
@ -344,7 +344,7 @@ LEVEL *LoadLevel(char *filename) {
} }
for(node2 = node->children; node2 != NULL; node2 = node2->next) { for(node2 = node->children; node2 != NULL; node2 = node2->next) {
if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, "triangle")) level->gates[i].nWalls++; if(node2->type == XML_ELEMENT_NODE && !xmlStrcmp(node2->name, (xmlChar*)"triangle")) level->gates[i].nWalls++;
} }
level->gates[i].walls = calloc(level->gates[i].nWalls, sizeof(WALL)); level->gates[i].walls = calloc(level->gates[i].nWalls, sizeof(WALL));

View file

@ -10,7 +10,7 @@ int input = 0;
int falling = 0; int falling = 0;
PLAYER player = { PLAYER player = {
{0.0, 0.0, 0.0}, {{0.0, 0.0, 0.0}},
0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
100, 100, 0 100, 100, 0
}; };
@ -34,16 +34,16 @@ void MouseInput(int x, int y) {
void DoInput(int delta) { void DoInput(int delta) {
int i, wasfalling = falling; int i, wasfalling = falling;
int g; //int g;
VERTEX pos; VERTEX pos;
int room = player.room; int room = player.room;
VECTOR move = {0.0, 0.0, 0.0}; VECTOR move = {{0.0, 0.0, 0.0}};
VECTOR v = {0.0, -1.0, 0.0}; VECTOR v = {{0.0, -1.0, 0.0}};
float s, c; float s, c;
float f = 0.0; float f = 0.0;
VERTEX p1, p2; //VERTEX p1, p2;
VECTOR v1, v2; //VECTOR v1, v2;
MATRIX transform; //MATRIX transform;
objrot += 0.01*delta; objrot += 0.01*delta;
if(objrot > 360.0) objrot -= 360.0; if(objrot > 360.0) objrot -= 360.0;

View file

@ -23,13 +23,13 @@ static int SortByTex(const void *p1, const void *p2) {
} }
void Render() { void Render() {
GLfloat std_emission[] = {0.0, 0.0, 0.0, 1.0}; //GLfloat std_emission[] ={{0.0, 0.0, 0.0, 1.0};
MATRIX rotate = { MATRIX rotate = {.f = {
player.rotycos, 0.0, -player.rotysin, 0.0, player.rotycos, 0.0, -player.rotysin, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
player.rotysin, 0.0, player.rotycos, 0.0, player.rotysin, 0.0, player.rotycos, 0.0,
0.0, 0.0, 0.0, 1.0 0.0, 0.0, 0.0, 1.0
}; }};
POLYGON_LIST *room; POLYGON_LIST *room;
int i, j, k; int i, j, k;
float d; float d;