More windows stuff
This commit is contained in:
parent
faad866c8b
commit
4bbe82a705
|
@ -36,7 +36,9 @@ if (NOT WIN32)
|
|||
)
|
||||
endif (NOT WIN32)
|
||||
|
||||
if (NOT WIN32)
|
||||
add_definitions("-std=gnu11 -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes")
|
||||
endif (NOT WIN32)
|
||||
|
||||
# PROGRAMS:
|
||||
add_executable(breakhack
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define ACTIONTEXT_H_
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "position.h"
|
||||
#include "texture.h"
|
||||
|
|
|
@ -94,7 +94,7 @@ ht_set(Hashtable *table, const char *key, void *val)
|
|||
/* New entry */
|
||||
newEntry = entry_create(key, val);
|
||||
|
||||
if (next == table->entries[hashkey] && last == NULL) {
|
||||
if (next == table->entries[hashkey]) {
|
||||
table->entries[hashkey] = newEntry;
|
||||
newEntry->next = next;
|
||||
} else if(next == NULL) {
|
||||
|
|
|
@ -23,7 +23,7 @@ LinkedList* linkedlist_node_create(void)
|
|||
return newList;
|
||||
}
|
||||
|
||||
LinkedList* linkedlist_create()
|
||||
LinkedList* linkedlist_create(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ void map_render(Map *map, Camera *cam)
|
|||
}
|
||||
|
||||
monsterItem = map->monsters;
|
||||
while (monsterItem) {
|
||||
while (monsterItem != NULL) {
|
||||
Monster *monster = monsterItem->data;
|
||||
monsterItem = monsterItem->next;
|
||||
monster_render(monster, cam);
|
||||
|
|
|
@ -62,8 +62,8 @@ int l_map_set_current_room(lua_State *L)
|
|||
unsigned int room_x, room_y;
|
||||
|
||||
map = luaL_checkmap(L, 1);
|
||||
room_x = luaL_checkinteger(L, 2);
|
||||
room_y = luaL_checkinteger(L, 3);
|
||||
room_x = (int) luaL_checkinteger(L, 2);
|
||||
room_y = (int) luaL_checkinteger(L, 3);
|
||||
|
||||
map->currentRoom = (Position) { room_x, room_y };
|
||||
|
||||
|
@ -96,8 +96,8 @@ extract_tile_data(lua_State *L,
|
|||
bool collider, lightsource;
|
||||
|
||||
map = luaL_checkmap(L, 1);
|
||||
tile_x = luaL_checkinteger(L, 2);
|
||||
tile_y = luaL_checkinteger(L, 3);
|
||||
tile_x = (int) luaL_checkinteger(L, 2);
|
||||
tile_y = (int) luaL_checkinteger(L, 3);
|
||||
|
||||
// Read the table
|
||||
lua_settop(L, 4);
|
||||
|
@ -111,10 +111,10 @@ extract_tile_data(lua_State *L,
|
|||
lua_getfield(L, 4, "isCollider");
|
||||
lua_getfield(L, 4, "isLightSource");
|
||||
|
||||
t_index0 = luaL_checkinteger(L, -6);
|
||||
t_index1 = luaL_checkinteger(L, -5);
|
||||
tile_clip_x = luaL_checkinteger(L, -4);
|
||||
tile_clip_y = luaL_checkinteger(L, -3);
|
||||
t_index0 = (int) luaL_checkinteger(L, -6);
|
||||
t_index1 = (int) luaL_checkinteger(L, -5);
|
||||
tile_clip_x = (int) luaL_checkinteger(L, -4);
|
||||
tile_clip_y = (int) luaL_checkinteger(L, -3);
|
||||
collider = lua_toboolean(L, -2);
|
||||
lightsource = lua_toboolean(L, -1);
|
||||
|
||||
|
@ -156,8 +156,8 @@ l_add_monster(lua_State *L)
|
|||
|
||||
renderer = luaL_checksdlrenderer(L);
|
||||
map = luaL_checkmap(L, 1);
|
||||
x = luaL_checkinteger(L, 2);
|
||||
y = luaL_checkinteger(L, 3);
|
||||
x = (int) luaL_checkinteger(L, 2);
|
||||
y = (int) luaL_checkinteger(L, 3);
|
||||
|
||||
// Read the table
|
||||
lua_settop(L, 4);
|
||||
|
@ -172,10 +172,10 @@ l_add_monster(lua_State *L)
|
|||
|
||||
texture_path_1 = luaL_checkstring(L, -6);
|
||||
texture_path_2 = luaL_checkstring(L, -5);
|
||||
clip_x = luaL_checkinteger(L, -4);
|
||||
clip_y = luaL_checkinteger(L, -3);
|
||||
nstate = luaL_checkinteger(L, -2);
|
||||
cstate = luaL_checkinteger(L, -1);
|
||||
clip_x = (int) luaL_checkinteger(L, -4);
|
||||
clip_y = (int) luaL_checkinteger(L, -3);
|
||||
nstate = (int) luaL_checkinteger(L, -2);
|
||||
cstate = (int) luaL_checkinteger(L, -1);
|
||||
|
||||
texture1 = map_add_monster_texture(map, texture_path_1, renderer);
|
||||
texture2 = map_add_monster_texture(map, texture_path_2, renderer);
|
||||
|
|
10
src/player.c
10
src/player.c
|
@ -155,23 +155,23 @@ player_create(class_t class, SDL_Renderer *renderer)
|
|||
char asset[100];
|
||||
switch (class) {
|
||||
case ENGINEER:
|
||||
_strcpy(asset, 100, "assets/Commissions/Engineer.png");
|
||||
m_strcpy(asset, 100, "assets/Commissions/Engineer.png");
|
||||
player->stats = (Stats) ENGINEER_STATS;
|
||||
break;
|
||||
case MAGE:
|
||||
_strcpy(asset, 100, "assets/Commissions/Mage.png");
|
||||
m_strcpy(asset, 100, "assets/Commissions/Mage.png");
|
||||
player->stats = (Stats) MAGE_STATS;
|
||||
break;
|
||||
case PALADIN:
|
||||
_strcpy(asset, 100, "assets/Commissions/Paladin.png");
|
||||
m_strcpy(asset, 100, "assets/Commissions/Paladin.png");
|
||||
player->stats = (Stats) PALADIN_STATS;
|
||||
break;
|
||||
case ROGUE:
|
||||
_strcpy(asset, 100, "assets/Commissions/Rogue.png");
|
||||
m_strcpy(asset, 100, "assets/Commissions/Rogue.png");
|
||||
player->stats = (Stats) ROGUE_STATS;
|
||||
break;
|
||||
case WARRIOR:
|
||||
_strcpy(asset, 100, "assets/Commissions/Warrior.png");
|
||||
m_strcpy(asset, 100, "assets/Commissions/Warrior.png");
|
||||
player->stats = (Stats) WARRIOR_STATS;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ get_random(unsigned int max)
|
|||
{
|
||||
static bool seeded = false;
|
||||
if (!seeded) {
|
||||
srand(time(NULL));
|
||||
srand((unsigned int) time(NULL));
|
||||
seeded = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void roommatrix_populate_from_map(RoomMatrix *rm, Map *m)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef WINDOWS
|
||||
#ifndef _WIN32
|
||||
static int
|
||||
min(int a, int b)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ max(int a, int b)
|
|||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
|
||||
void
|
||||
roommatrix_update_with_player(RoomMatrix *rm, Player *p)
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
#include "defines.h"
|
||||
|
||||
#ifndef WINDOWS
|
||||
#ifndef _WIN32
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "screenresolution.h"
|
||||
|
||||
Dimension getScreenDimensions(void)
|
||||
{
|
||||
#ifndef WINDOWS
|
||||
#ifndef _WIN32
|
||||
Display *d = XOpenDisplay(NULL);
|
||||
Screen *s = DefaultScreenOfDisplay(d);
|
||||
Dimension dim = (Dimension) { s->width, s->height };
|
||||
|
||||
free(d);
|
||||
free(s);
|
||||
#else
|
||||
#else // _WIN32
|
||||
Dimension dim = (Dimension) { 1920, 1080 };
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
|
||||
return dim;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ Sprite* sprite_create_default(void)
|
|||
*s = (Sprite) {
|
||||
{ NULL, NULL },
|
||||
(SDL_Rect) { 0, 0, 16, 16 },
|
||||
false, pos,
|
||||
false,
|
||||
pos,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
|
|
10
src/util.c
10
src/util.c
|
@ -9,7 +9,7 @@
|
|||
#include "util.h"
|
||||
|
||||
void
|
||||
_strcpy(char *restrict dest, size_t destsz, char *restrict src)
|
||||
m_strcpy(char *dest, size_t destsz, char *src)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
UNUSED(destsz);
|
||||
|
@ -20,9 +20,9 @@ _strcpy(char *restrict dest, size_t destsz, char *restrict src)
|
|||
}
|
||||
|
||||
void
|
||||
_strncat(char *restrict dest,
|
||||
m_strncat(char *dest,
|
||||
size_t destsz,
|
||||
char *restrict src,
|
||||
char *src,
|
||||
size_t srcsz)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
|
@ -38,8 +38,8 @@ void fatal(char *message)
|
|||
{
|
||||
char error_message[100];
|
||||
|
||||
_strcpy(error_message, 100, "[!!] Fatal Error ");
|
||||
_strncat(error_message, 100, message, 83);
|
||||
m_strcpy(error_message, 100, "[!!] Fatal Error ");
|
||||
m_strncat(error_message, 100, message, 83);
|
||||
perror(error_message);
|
||||
exit(-1);
|
||||
}
|
||||
|
|
|
@ -5,12 +5,9 @@ void fatal(char *message);
|
|||
|
||||
void *ec_malloc(unsigned int size);
|
||||
|
||||
void _strcpy(char *restrict dest, size_t destsz, char *restrict src);
|
||||
void m_strcpy(char *dest, size_t destsz, char *src);
|
||||
|
||||
void
|
||||
_strncat(char *restrict dest,
|
||||
size_t destsz,
|
||||
char *restrict src,
|
||||
size_t srcsz);
|
||||
m_strncat(char *dest, size_t destsz, char *src, size_t srcsz);
|
||||
|
||||
#endif // UTIL_H_
|
||||
|
|
Loading…
Reference in New Issue