Fixed a massive error in hashtable.

Compile on windows now works fine.
This commit is contained in:
Linus Probert 2017-12-20 18:56:28 +01:00
parent c128a5dc39
commit d4fa9f89d6
4 changed files with 12 additions and 9 deletions

View File

@ -119,7 +119,7 @@ ht_get(Hashtable *table, const char *key)
entry = table->entries[hashkey]; entry = table->entries[hashkey];
while (entry && entry->key && strcmp(entry->key, key) > 0) { while (entry && entry->key && strcmp(entry->key, key) < 0) {
entry = entry->next; entry = entry->next;
} }

View File

@ -3,10 +3,10 @@
#include "linkedlist.h" #include "linkedlist.h"
static static
void *linkedlist_malloc(unsigned int size) LinkedList *linkedlist_malloc(void)
{ {
void *ptr; LinkedList *ptr;
ptr = malloc(size); ptr = malloc(sizeof(LinkedList));
if (ptr == NULL) { if (ptr == NULL) {
perror("[!!] Fatal error in linkedlist_malloc() on memory allocation"); perror("[!!] Fatal error in linkedlist_malloc() on memory allocation");
exit(-1); exit(-1);
@ -17,7 +17,7 @@ void *linkedlist_malloc(unsigned int size)
static static
LinkedList* linkedlist_node_create(void) LinkedList* linkedlist_node_create(void)
{ {
LinkedList *newList = linkedlist_malloc(sizeof(LinkedList)); LinkedList *newList = linkedlist_malloc();
newList->next = NULL; newList->next = NULL;
newList->data = NULL; newList->data = NULL;
return newList; return newList;

View File

@ -32,7 +32,7 @@ bool initSDL(void)
if (dim.height > 768) { if (dim.height > 768) {
printf("[**] Hi resolution screen detected (%u x %u)\n", dim.width, dim.height); printf("[**] Hi resolution screen detected (%u x %u)\n", dim.width, dim.height);
scale = ((double) dim.height)/768; scale = ((double) dim.height)/1080;
printf("[**] Scaling by %f\n", scale); printf("[**] Scaling by %f\n", scale);
} }
@ -44,8 +44,8 @@ bool initSDL(void)
gWindow = SDL_CreateWindow("Breakhack", gWindow = SDL_CreateWindow("Breakhack",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH * scale, (int)(SCREEN_WIDTH * scale),
SCREEN_HEIGHT * scale, (int)(SCREEN_HEIGHT * scale),
SDL_WINDOW_SHOWN); SDL_WINDOW_SHOWN);
if (gWindow == NULL) if (gWindow == NULL)
{ {
@ -182,6 +182,7 @@ void close(void)
roommatrix_destroy(gRoomMatrix); roommatrix_destroy(gRoomMatrix);
SDL_DestroyWindow(gWindow); SDL_DestroyWindow(gWindow);
gWindow = NULL; gWindow = NULL;
TTF_Quit();
IMG_Quit(); IMG_Quit();
SDL_Quit(); SDL_Quit();
} }

View File

@ -142,7 +142,9 @@ roommatrix_render_lightmap(RoomMatrix *matrix, Camera *cam)
for (i = 0; i < MAP_ROOM_WIDTH; ++i) { for (i = 0; i < MAP_ROOM_WIDTH; ++i) {
for (j = 0; j < MAP_ROOM_HEIGHT; ++j) { for (j = 0; j < MAP_ROOM_HEIGHT; ++j) {
light = max(0, 230 - matrix->spaces[i][j].light); light = 245 - matrix->spaces[i][j].light;
if (light < 0)
light = 0;
SDL_SetRenderDrawColor(cam->renderer, SDL_SetRenderDrawColor(cam->renderer,
0, 0, 0, light); 0, 0, 0, light);
SDL_Rect box = (SDL_Rect) { SDL_Rect box = (SDL_Rect) {