make the thing work for msvc

This commit is contained in:
learn_more 2013-02-15 01:12:30 +01:00
parent bbf29b7651
commit 6a3b1dff36
19 changed files with 452 additions and 99 deletions

8
.gitignore vendored
View File

@ -25,3 +25,11 @@ gmon.out
# kate # kate
*.kate-swp *.kate-swp
#visual studio files (personal config and whatnot)
*.suo
*.ncb
*.user
msvc/Debug
msvc/Release
build/msvc

View File

@ -40,25 +40,44 @@
//define RENDER_FACE_COUNT 2 //define RENDER_FACE_COUNT 2
#ifndef _MSC_VER
#define PACK_START
#define PACK_END
#include <immintrin.h> #include <immintrin.h>
#include <stdint.h>
#else
#define __attribute__(x)
#define PACK_START __pragma( pack(push, 1) )
#define PACK_END __pragma( pack(pop) )
typedef unsigned int uint32_t;
#define snprintf sprintf_s
#define _USE_MATH_DEFINES //M_PI and whatnot from math.h
#pragma warning( disable: 4200 4244 4996)
#endif
#include <omp.h> #include <omp.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <sys/time.h>
#ifndef WIN32 #ifndef WIN32
#include <sys/time.h>
#include <signal.h> #include <signal.h>
#endif #endif
#include <math.h> #include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <lua.h> #include <lua.h>
#include <lualib.h> #include <lualib.h>
#include <lauxlib.h> #include <lauxlib.h>
#ifdef __cplusplus
};
#endif
#ifndef DEDI #ifndef DEDI
#include <SDL.h> #include <SDL.h>
@ -76,7 +95,6 @@
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0501
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
extern WSADATA windows_sucks;
#else #else
@ -118,6 +136,7 @@ enum
#ifdef __SSE__ #ifdef __SSE__
__attribute__((aligned(16))) __attribute__((aligned(16)))
#endif #endif
PACK_START
typedef union vec4f typedef union vec4f
{ {
struct { float x,y,z,w; } __attribute__((__packed__)) p; struct { float x,y,z,w; } __attribute__((__packed__)) p;
@ -135,6 +154,7 @@ typedef struct matrix
//column-major! //column-major!
vec4f_t c[4]; vec4f_t c[4];
} __attribute__((__packed__)) matrix_t; } __attribute__((__packed__)) matrix_t;
PACK_END
typedef struct camera typedef struct camera
{ {
@ -145,12 +165,14 @@ typedef struct camera
float mpx,mpy,mpz,mppad; float mpx,mpy,mpz,mppad;
} camera_t; } camera_t;
PACK_START
typedef struct model_point typedef struct model_point
{ {
uint16_t radius; uint16_t radius;
int16_t x,y,z; int16_t x,y,z;
uint8_t b,g,r,resv1; uint8_t b,g,r,resv1;
} __attribute__((__packed__)) model_point_t; } __attribute__((__packed__)) model_point_t;
PACK_END
typedef struct model model_t; typedef struct model model_t;
typedef struct model_bone typedef struct model_bone
@ -176,6 +198,7 @@ struct model
model_bone_t *bones[]; model_bone_t *bones[];
}; };
PACK_START
// source: http://paulbourke.net/dataformats/tga/ // source: http://paulbourke.net/dataformats/tga/
typedef struct img_tgahead typedef struct img_tgahead
{ {
@ -192,6 +215,7 @@ typedef struct img_tgahead
uint8_t bpp; uint8_t bpp;
uint8_t flags; uint8_t flags;
} __attribute__((__packed__)) img_tgahead_t; } __attribute__((__packed__)) img_tgahead_t;
PACK_END
typedef struct img typedef struct img
{ {
@ -319,10 +343,6 @@ typedef struct client
int spkt_ppos,spkt_len; int spkt_ppos,spkt_len;
} client_t; } client_t;
struct netdata
{
int sockfd;
} netdata_t;
#define SOCKFD_NONE -1 #define SOCKFD_NONE -1
#define SOCKFD_LOCAL -2 #define SOCKFD_LOCAL -2

20
msvc/iceball.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iceball", "iceball.vcproj", "{CD5FA57E-F7A1-4CC0-B8B0-043E78858D90}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD5FA57E-F7A1-4CC0-B8B0-043E78858D90}.Debug|Win32.ActiveCfg = Debug|Win32
{CD5FA57E-F7A1-4CC0-B8B0-043E78858D90}.Debug|Win32.Build.0 = Debug|Win32
{CD5FA57E-F7A1-4CC0-B8B0-043E78858D90}.Release|Win32.ActiveCfg = Release|Win32
{CD5FA57E-F7A1-4CC0-B8B0-043E78858D90}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

305
msvc/iceball.vcproj Normal file
View File

@ -0,0 +1,305 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="iceball"
ProjectGUID="{CD5FA57E-F7A1-4CC0-B8B0-043E78858D90}"
RootNamespace="iceball"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../include;../winlibs/lua;../winlibs/SDL;../winlibs/zlib;../winlibs/glew"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;USE_OPENGL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
CompileAs="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib SDLmain.lib lua5.1.lib ws2_32.lib zdll.lib glew32.lib opengl32.lib"
OutputFile="$(SolutionDir)\..\build\msvc\$(ProjectName).exe"
LinkIncremental="2"
AdditionalLibraryDirectories="../winlibs"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Copying dependency dll&apos;s"
CommandLine="copy $(SolutionDir)\..\winlibs\*.dll $(TargetDir)"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../include;../winlibs/lua;../winlibs/SDL;../winlibs/zlib;../winlibs/glew"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;USE_OPENGL"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib SDLmain.lib lua5.1.lib ws2_32.lib zdll.lib glew32.lib opengl32.lib"
OutputFile="$(SolutionDir)\..\build\msvc\$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="../winlibs"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Copying dependency dll&apos;s"
CommandLine="copy $(SolutionDir)\..\winlibs\*.dll $(TargetDir)"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\src\dsp.c"
>
</File>
<File
RelativePath="..\src\img.c"
>
</File>
<File
RelativePath="..\src\json.c"
>
</File>
<File
RelativePath="..\src\logtxt.c"
>
</File>
<File
RelativePath="..\src\lua.c"
>
</File>
<File
RelativePath="..\src\main.c"
>
</File>
<File
RelativePath="..\src\map.c"
>
</File>
<File
RelativePath="..\src\model.c"
>
</File>
<File
RelativePath="..\src\network.c"
>
</File>
<File
RelativePath="..\src\path.c"
>
</File>
<File
RelativePath="..\src\vecmath.c"
>
</File>
<File
RelativePath="..\src\wav.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\include\common.h"
>
</File>
<File
RelativePath="..\src\lua_base.h"
>
</File>
<File
RelativePath="..\src\lua_camera.h"
>
</File>
<File
RelativePath="..\src\lua_fetch.h"
>
</File>
<File
RelativePath="..\src\lua_image.h"
>
</File>
<File
RelativePath="..\src\lua_input.h"
>
</File>
<File
RelativePath="..\src\lua_json.h"
>
</File>
<File
RelativePath="..\src\lua_map.h"
>
</File>
<File
RelativePath="..\src\lua_model.h"
>
</File>
<File
RelativePath="..\src\lua_net.h"
>
</File>
<File
RelativePath="..\src\lua_util.h"
>
</File>
<File
RelativePath="..\src\lua_wav.h"
>
</File>
</Filter>
<Filter
Name="gl"
>
<File
RelativePath="..\src\gl\render.c"
>
</File>
<File
RelativePath="..\src\gl\render_img.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -101,7 +101,7 @@ float wavelength2frequency(int rate, float wavelength)
/* 12-tone scale MIDI notes are defined by this log function. 60 is "C-4", 69 is "A-4". */ /* 12-tone scale MIDI notes are defined by this log function. 60 is "C-4", 69 is "A-4". */
float frequency2midinote(float frequency) float frequency2midinote(float frequency)
{ return 69 + 12*(log(frequency/440.)/log(2)); } { return 69 + 12*(log(frequency/440.)/log(2.)); }
float midinote2frequency(float midinote) float midinote2frequency(float midinote)
{ return pow(2,(midinote-69)/12)*440; } { return pow(2,(midinote-69)/12)*440; }

View File

@ -105,7 +105,7 @@ void render_update_vbo(float **arr, int *len, int *max, int newlen)
xlen = newlen + 10; xlen = newlen + 10;
} }
*arr = realloc(*arr, xlen*sizeof(float)*6); *arr = (float*)realloc(*arr, xlen*sizeof(float)*6);
*max = xlen; *max = xlen;
} }

View File

@ -61,7 +61,7 @@ img_t *img_parse_tga(int len, const char *data)
// jump to palette // jump to palette
// load palette if necessary // load palette if necessary
uint32_t *palette = (head.cmtype == 1 ? malloc(head.cmlen*4) : NULL); uint32_t *palette = (head.cmtype == 1 ? (uint32_t*)malloc(head.cmlen*4) : NULL);
if(palette != NULL) if(palette != NULL)
for(i = 0; i < head.cmlen; i++) for(i = 0; i < head.cmlen; i++)
@ -76,7 +76,7 @@ img_t *img_parse_tga(int len, const char *data)
} }
// allocate + stash // allocate + stash
img_t *img = malloc(sizeof(img_t)+4*head.width*head.height); img_t *img = (img_t*)malloc(sizeof(img_t)+4*head.width*head.height);
// TODO: check if NULL // TODO: check if NULL
img->head = head; img->head = head;
img->udtype = UD_IMG; img->udtype = UD_IMG;

View File

@ -104,7 +104,7 @@ int json_parse_string(lua_State *L, const char **p)
int sbuf_pos = 0; int sbuf_pos = 0;
int sbuf_len = 64; int sbuf_len = 64;
char *sbuf = malloc(sbuf_len); char *sbuf = (char*)malloc(sbuf_len);
// TODO: throughout this code, check if sbuf is NULL // TODO: throughout this code, check if sbuf is NULL
int uchr = 0; int uchr = 0;
int lastwasr = 0; int lastwasr = 0;
@ -177,7 +177,7 @@ int json_parse_string(lua_State *L, const char **p)
if(sbuf_pos+4 >= sbuf_len) if(sbuf_pos+4 >= sbuf_len)
{ {
sbuf_len <<= 1; sbuf_len <<= 1;
sbuf = realloc(sbuf, sbuf_len); sbuf = (char*)realloc(sbuf, sbuf_len);
//printf("%i %016llX\n", sbuf_len, sbuf); //printf("%i %016llX\n", sbuf_len, sbuf);
} }

View File

@ -22,7 +22,7 @@ int icelua_fn_client_img_blit(lua_State *L)
int dx, dy, bw, bh, sx, sy; int dx, dy, bw, bh, sx, sy;
uint32_t color; uint32_t color;
img_t *img = lua_touserdata(L, 1); img_t *img = (img_t*)lua_touserdata(L, 1);
if(img == NULL || img->udtype != UD_IMG) if(img == NULL || img->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");
@ -37,7 +37,7 @@ int icelua_fn_client_img_blit(lua_State *L)
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
render_blit_img(screen->pixels, screen->w, screen->h, screen->pitch/4, render_blit_img((uint32_t*)screen->pixels, screen->w, screen->h, screen->pitch/4,
img, dx, dy, bw, bh, sx, sy, color); img, dx, dy, bw, bh, sx, sy, color);
#endif #endif
@ -50,10 +50,10 @@ int icelua_fn_client_img_blit_to(lua_State *L)
int dx, dy, bw, bh, sx, sy; int dx, dy, bw, bh, sx, sy;
uint32_t color; uint32_t color;
img_t *dest = lua_touserdata(L, 1); img_t *dest = (img_t*)lua_touserdata(L, 1);
if(dest == NULL || dest->udtype != UD_IMG) if(dest == NULL || dest->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");
img_t *source = lua_touserdata(L, 2); img_t *source = (img_t*)lua_touserdata(L, 2);
if(source == NULL || source->udtype != UD_IMG) if(source == NULL || source->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");
@ -88,7 +88,7 @@ int icelua_fn_common_img_load(lua_State *L)
lua_pushvalue(L, 1); lua_pushvalue(L, 1);
lua_call(L, 2, 1); lua_call(L, 2, 1);
img_t *img = lua_touserdata(L, -1); img_t *img = (img_t*)lua_touserdata(L, -1);
if(img == NULL) if(img == NULL)
return 0; return 0;
@ -110,7 +110,7 @@ int icelua_fn_common_img_new(lua_State *L)
if(w < 1 || h < 1) if(w < 1 || h < 1)
return luaL_error(L, "image too small"); return luaL_error(L, "image too small");
img_t *img = malloc(sizeof(img_t)+(w*h*sizeof(uint32_t))); img_t *img = (img_t*)malloc(sizeof(img_t)+(w*h*sizeof(uint32_t)));
if(img == NULL) if(img == NULL)
return luaL_error(L, "could not allocate memory"); return luaL_error(L, "could not allocate memory");
@ -138,11 +138,9 @@ int icelua_fn_common_img_new(lua_State *L)
int icelua_fn_common_img_pixel_set(lua_State *L) int icelua_fn_common_img_pixel_set(lua_State *L)
{ {
int i;
int top = icelua_assert_stack(L, 4, 4); int top = icelua_assert_stack(L, 4, 4);
img_t *img = lua_touserdata(L, 1); img_t *img = (img_t*)lua_touserdata(L, 1);
if(img == NULL || img->udtype != UD_IMG) if(img == NULL || img->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");
int x = lua_tointeger(L, 2); int x = lua_tointeger(L, 2);
@ -163,7 +161,7 @@ int icelua_fn_common_img_fill(lua_State *L)
int top = icelua_assert_stack(L, 2, 2); int top = icelua_assert_stack(L, 2, 2);
img_t *img = lua_touserdata(L, 1); img_t *img = (img_t*)lua_touserdata(L, 1);
if(img == NULL || img->udtype != UD_IMG) if(img == NULL || img->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");
uint32_t color = lua_tointeger(L, 2); uint32_t color = lua_tointeger(L, 2);
@ -178,7 +176,7 @@ int icelua_fn_common_img_free(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
img_t *img = lua_touserdata(L, 1); img_t *img = (img_t*)lua_touserdata(L, 1);
if(img == NULL || img->udtype != UD_IMG) if(img == NULL || img->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");
@ -191,7 +189,7 @@ int icelua_fn_common_img_get_dims(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
img_t *img = lua_touserdata(L, 1); img_t *img = (img_t*)lua_touserdata(L, 1);
if(img == NULL || img->udtype != UD_IMG) if(img == NULL || img->udtype != UD_IMG)
return luaL_error(L, "not an image"); return luaL_error(L, "not an image");

View File

@ -54,7 +54,7 @@ int icelua_fn_common_map_new(lua_State *L)
return luaL_error(L, "map size too small"); return luaL_error(L, "map size too small");
// XXX: shouldn't this be in map.c? // XXX: shouldn't this be in map.c?
map_t *map = malloc(sizeof(map_t)); map_t *map = (map_t*)malloc(sizeof(map_t));
if(map == NULL) if(map == NULL)
{ {
int err = errno; int err = errno;
@ -64,7 +64,7 @@ int icelua_fn_common_map_new(lua_State *L)
map->xlen = xlen; map->xlen = xlen;
map->ylen = ylen; map->ylen = ylen;
map->zlen = zlen; map->zlen = zlen;
map->pillars = malloc(xlen*zlen*sizeof(uint8_t *)); map->pillars = (uint8_t**)malloc(xlen*zlen*sizeof(uint8_t *));
if(map->pillars == NULL) if(map->pillars == NULL)
{ {
int err = errno; int err = errno;
@ -77,7 +77,7 @@ int icelua_fn_common_map_new(lua_State *L)
for(z = 0, pi = 0; z < map->zlen; z++) for(z = 0, pi = 0; z < map->zlen; z++)
for(x = 0; x < map->xlen; x++, pi++) for(x = 0; x < map->xlen; x++, pi++)
{ {
uint8_t *p = map->pillars[pi] = malloc(16); uint8_t *p = map->pillars[pi] = (uint8_t*)malloc(16);
// TODO: check if NULL // TODO: check if NULL
uint8_t v = (uint8_t)(x^z); uint8_t v = (uint8_t)(x^z);
*(p++) = 1; *(p++) = 0; *(p++) = 0; *(p++) = 0; *(p++) = 1; *(p++) = 0; *(p++) = 0; *(p++) = 0;
@ -97,7 +97,7 @@ int icelua_fn_common_map_new(lua_State *L)
int icelua_fn_common_map_free(lua_State *L) int icelua_fn_common_map_free(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
map_t *map = lua_touserdata(L, 1); map_t *map = (map_t*)lua_touserdata(L, 1);
if(map == NULL || map->udtype != UD_MAP) if(map == NULL || map->udtype != UD_MAP)
return luaL_error(L, "not a map"); return luaL_error(L, "not a map");
@ -109,7 +109,7 @@ int icelua_fn_common_map_free(lua_State *L)
int icelua_fn_common_map_set(lua_State *L) int icelua_fn_common_map_set(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
map_t *map = lua_touserdata(L, 1); map_t *map = (map_t*)lua_touserdata(L, 1);
if((map == NULL || map->udtype != UD_MAP) && !lua_isnil(L, 1)) if((map == NULL || map->udtype != UD_MAP) && !lua_isnil(L, 1))
return luaL_error(L, "not a map"); return luaL_error(L, "not a map");
@ -142,7 +142,7 @@ int icelua_fn_common_map_save(lua_State *L)
{ {
int top = icelua_assert_stack(L, 2, 3); int top = icelua_assert_stack(L, 2, 3);
map_t *map = lua_touserdata(L, 1); map_t *map = (map_t*)lua_touserdata(L, 1);
if(map == NULL || map->udtype != UD_MAP) if(map == NULL || map->udtype != UD_MAP)
return luaL_error(L, "not a map"); return luaL_error(L, "not a map");
const char *fname = lua_tostring(L, 2); const char *fname = lua_tostring(L, 2);
@ -312,7 +312,7 @@ int icelua_fn_common_map_pillar_set(lua_State *L)
uint8_t *p = map->pillars[idx]; uint8_t *p = map->pillars[idx];
if((p[0]+1)*4 < tlen) if((p[0]+1)*4 < tlen)
{ {
p = map->pillars[idx] = realloc(p, tlen+4); p = map->pillars[idx] = (uint8_t*)realloc(p, tlen+4);
p[0] = (tlen>>2)-1; p[0] = (tlen>>2)-1;
} }

View File

@ -53,7 +53,7 @@ int icelua_fn_common_model_save_pmf(lua_State *L)
{ {
int top = icelua_assert_stack(L, 2, 2); int top = icelua_assert_stack(L, 2, 2);
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL) if(pmf == NULL)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
const char *fname = lua_tostring(L, 2); const char *fname = lua_tostring(L, 2);
@ -76,7 +76,7 @@ int icelua_fn_common_model_free(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -89,7 +89,7 @@ int icelua_fn_common_model_len(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -104,7 +104,7 @@ int icelua_fn_common_model_bone_new(lua_State *L)
int top = icelua_assert_stack(L, 1, 2); int top = icelua_assert_stack(L, 1, 2);
int ptmax = 20; int ptmax = 20;
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -138,7 +138,7 @@ int icelua_fn_common_model_bone_free(lua_State *L)
int top = icelua_assert_stack(L, 1, 2); int top = icelua_assert_stack(L, 1, 2);
int boneidx; int boneidx;
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -156,7 +156,7 @@ int icelua_fn_common_model_bone_get(lua_State *L)
int i; int i;
int top = icelua_assert_stack(L, 2, 2); int top = icelua_assert_stack(L, 2, 2);
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -205,7 +205,7 @@ int icelua_fn_common_model_bone_set(lua_State *L)
int i; int i;
int top = icelua_assert_stack(L, 4, 4); int top = icelua_assert_stack(L, 4, 4);
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -303,7 +303,7 @@ int icelua_fn_common_model_bone_find(lua_State *L)
int i; int i;
int top = icelua_assert_stack(L, 2, 2); int top = icelua_assert_stack(L, 2, 2);
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -334,7 +334,7 @@ int icelua_fn_client_model_render_bone_global(lua_State *L)
float ry, rx, ry2; float ry, rx, ry2;
float scale; float scale;
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -356,7 +356,7 @@ int icelua_fn_client_model_render_bone_global(lua_State *L)
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
render_pmf_bone(screen->pixels, screen->w, screen->h, screen->pitch/4, &tcam, render_pmf_bone((uint32_t*)screen->pixels, screen->w, screen->h, screen->pitch/4, &tcam,
bone, 0, px, py, pz, ry, rx, ry2, scale); bone, 0, px, py, pz, ry, rx, ry2, scale);
#endif #endif
@ -370,7 +370,7 @@ int icelua_fn_client_model_render_bone_local(lua_State *L)
float ry, rx, ry2; float ry, rx, ry2;
float scale; float scale;
model_t *pmf = lua_touserdata(L, 1); model_t *pmf = (model_t*)lua_touserdata(L, 1);
if(pmf == NULL || pmf->udtype != UD_PMF) if(pmf == NULL || pmf->udtype != UD_PMF)
return luaL_error(L, "not a model"); return luaL_error(L, "not a model");
@ -392,7 +392,7 @@ int icelua_fn_client_model_render_bone_local(lua_State *L)
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
render_pmf_bone(screen->pixels, screen->w, screen->h, screen->pitch/4, &tcam, render_pmf_bone((uint32_t*)screen->pixels, screen->w, screen->h, screen->pitch/4, &tcam,
bone, 1, px, py, pz, ry, rx, ry2, scale); bone, 1, px, py, pz, ry, rx, ry2, scale);
#endif #endif

View File

@ -114,7 +114,7 @@ int icelua_fn_common_net_pack(lua_State *L)
int slen = icelua_fnaux_net_packlen(L, fmt, top); int slen = icelua_fnaux_net_packlen(L, fmt, top);
if(slen < 0) if(slen < 0)
return luaL_error(L, "invalid pack format"); return luaL_error(L, "invalid pack format");
char *sbuf = malloc(slen+1); char *sbuf = (char*)malloc(slen+1);
// TODO: check if NULL // TODO: check if NULL
char *sstop = sbuf+slen; char *sstop = sbuf+slen;
*sstop = '\0'; *sstop = '\0';

View File

@ -46,7 +46,7 @@ int icelua_fn_client_wav_play_global(lua_State *L)
{ {
int top = icelua_assert_stack(L, 4, 7); int top = icelua_assert_stack(L, 4, 7);
wav_t *wav = lua_touserdata(L, 1); wav_t *wav = (wav_t*)lua_touserdata(L, 1);
if(wav == NULL || wav->udtype != UD_WAV) if(wav == NULL || wav->udtype != UD_WAV)
return luaL_error(L, "not a wav"); return luaL_error(L, "not a wav");
float x = lua_tonumber(L, 2); float x = lua_tonumber(L, 2);
@ -77,7 +77,7 @@ int icelua_fn_client_wav_play_local(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 7); int top = icelua_assert_stack(L, 1, 7);
wav_t *wav = lua_touserdata(L, 1); wav_t *wav = (wav_t*)lua_touserdata(L, 1);
if(wav == NULL || wav->udtype != UD_WAV) if(wav == NULL || wav->udtype != UD_WAV)
return luaL_error(L, "not a wav"); return luaL_error(L, "not a wav");
float x = (top < 2 ? 0.0f : lua_tonumber(L, 2)); float x = (top < 2 ? 0.0f : lua_tonumber(L, 2));
@ -216,7 +216,7 @@ int icelua_fn_common_wav_free(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
wav_t *wav = lua_touserdata(L, 1); wav_t *wav = (wav_t*)lua_touserdata(L, 1);
if(wav == NULL || wav->udtype != UD_WAV) if(wav == NULL || wav->udtype != UD_WAV)
return luaL_error(L, "not a wav"); return luaL_error(L, "not a wav");

View File

@ -195,8 +195,9 @@ int update_client_cont1(void)
//printf("%.2f",); //printf("%.2f",);
// draw scene to cubemap // draw scene to cubemap
SDL_LockSurface(screen); SDL_LockSurface(screen);
//memset(screen->pixels, 0x51, screen->h*screen->pitch); //memset(screen->pixels, 0x51, screen->h*screen->pitch);
render_cubemap(screen->pixels, render_cubemap((uint32_t*)screen->pixels,
screen->w, screen->h, screen->pitch/4, screen->w, screen->h, screen->pitch/4,
&tcam, clmap); &tcam, clmap);
@ -455,8 +456,6 @@ void run_game(void)
tcam.mzy = 0.0f; tcam.mzy = 0.0f;
tcam.mzz = 1.0f; tcam.mzz = 1.0f;
int i;
//render_vxl_redraw(&tcam, clmap); //render_vxl_redraw(&tcam, clmap);
int quitflag = 0; int quitflag = 0;
@ -521,6 +520,9 @@ int print_usage(char *rname)
return 99; return 99;
} }
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if(argc <= 1) if(argc <= 1)

View File

@ -25,7 +25,7 @@ map_t *map_parse_root(const char *dend, const char *data, int xlen, int ylen, in
int taglen = (int)(dend-data); int taglen = (int)(dend-data);
map_t *map = malloc(sizeof(map_t)); map_t *map = (map_t*)malloc(sizeof(map_t));
if(map == NULL) if(map == NULL)
{ {
error_perror("map_parse_root: malloc"); error_perror("map_parse_root: malloc");
@ -38,7 +38,7 @@ map_t *map_parse_root(const char *dend, const char *data, int xlen, int ylen, in
map->ylen = ylen; map->ylen = ylen;
map->zlen = zlen; map->zlen = zlen;
map->pillars = malloc(map->xlen*map->zlen*sizeof(uint8_t *)); map->pillars = (uint8_t**)malloc(map->xlen*map->zlen*sizeof(uint8_t *));
if(map->pillars == NULL) if(map->pillars == NULL)
{ {
error_perror("map_parse_root: malloc(map->pillars)"); error_perror("map_parse_root: malloc(map->pillars)");
@ -91,7 +91,7 @@ map_t *map_parse_root(const char *dend, const char *data, int xlen, int ylen, in
} }
pillar_temp[0] = (ti>>2)-2; pillar_temp[0] = (ti>>2)-2;
map->pillars[pi] = malloc(ti); map->pillars[pi] = (uint8_t*)malloc(ti);
// TODO: check if NULL // TODO: check if NULL
memcpy(map->pillars[pi], pillar_temp, ti); memcpy(map->pillars[pi], pillar_temp, ti);
} }
@ -107,8 +107,6 @@ map_t *map_parse_root(const char *dend, const char *data, int xlen, int ylen, in
map_t *map_parse_aos(int len, const char *data) map_t *map_parse_aos(int len, const char *data)
{ {
int i;
if(data == NULL) if(data == NULL)
return NULL; return NULL;
@ -120,8 +118,6 @@ map_t *map_parse_aos(int len, const char *data)
map_t *map_parse_icemap(int len, const char *data) map_t *map_parse_icemap(int len, const char *data)
{ {
int i;
if(data == NULL) if(data == NULL)
return NULL; return NULL;
@ -236,8 +232,7 @@ char *map_serialise_icemap(map_t *map, int *len)
{ {
// TODO: make map_save_icemap rely on this // TODO: make map_save_icemap rely on this
int x,z,pi; int x,z,pi;
int i;
if(map == NULL) if(map == NULL)
{ {
fprintf(stderr, "map_serialise_icemap: map is NULL!\n"); fprintf(stderr, "map_serialise_icemap: map is NULL!\n");
@ -273,7 +268,7 @@ char *map_serialise_icemap(map_t *map, int *len)
+8+4+6+maplen +8+4+6+maplen
+8; +8;
char *buf = malloc(buflen); char *buf = (char*)malloc(buflen);
// TODO check if NULL // TODO check if NULL
memcpy(buf, "IceMap\x1A\x01MapData\xFF", 16); memcpy(buf, "IceMap\x1A\x01MapData\xFF", 16);
@ -318,7 +313,6 @@ char *map_serialise_icemap(map_t *map, int *len)
int map_save_icemap(map_t *map, const char *fname) int map_save_icemap(map_t *map, const char *fname)
{ {
int x,z,pi; int x,z,pi;
int i;
FILE *fp = fopen(fname, "wb"); FILE *fp = fopen(fname, "wb");
if(fp == NULL) if(fp == NULL)

View File

@ -19,7 +19,7 @@
model_t *model_new(int bonemax) model_t *model_new(int bonemax)
{ {
model_t *pmf = malloc(sizeof(model_t)+sizeof(model_bone_t *)*bonemax); model_t *pmf = (model_t*)malloc(sizeof(model_t)+sizeof(model_bone_t *)*bonemax);
// TODO: check if NULL // TODO: check if NULL
pmf->bonelen = 0; pmf->bonelen = 0;
@ -31,7 +31,7 @@ model_t *model_new(int bonemax)
model_t *model_extend(model_t *pmf, int bonemax) model_t *model_extend(model_t *pmf, int bonemax)
{ {
pmf = realloc(pmf, sizeof(model_t)+sizeof(model_bone_t *)*bonemax); pmf = (model_t*)realloc(pmf, sizeof(model_t)+sizeof(model_bone_t *)*bonemax);
// TODO: check if NULL // TODO: check if NULL
pmf->bonemax = bonemax; pmf->bonemax = bonemax;
@ -49,7 +49,7 @@ void model_free(model_t *pmf)
model_bone_t *model_bone_new(model_t *pmf, int ptmax) model_bone_t *model_bone_new(model_t *pmf, int ptmax)
{ {
model_bone_t *bone = malloc(sizeof(model_bone_t)+sizeof(model_point_t)*ptmax); model_bone_t *bone = (model_bone_t*)malloc(sizeof(model_bone_t)+sizeof(model_point_t)*ptmax);
// TODO: check if NULL // TODO: check if NULL
bone->ptlen = 0; bone->ptlen = 0;
@ -71,7 +71,7 @@ model_bone_t *model_bone_new(model_t *pmf, int ptmax)
model_bone_t *model_bone_extend(model_bone_t *bone, int ptmax) model_bone_t *model_bone_extend(model_bone_t *bone, int ptmax)
{ {
model_t *pmf = bone->parent; model_t *pmf = bone->parent;
bone = realloc(bone, sizeof(model_bone_t)+sizeof(model_point_t)*ptmax); bone = (model_bone_t*)realloc(bone, sizeof(model_bone_t)+sizeof(model_point_t)*ptmax);
// TODO: check if NULL // TODO: check if NULL
pmf->bones[bone->parent_idx] = bone; pmf->bones[bone->parent_idx] = bone;
@ -101,8 +101,6 @@ model_t *model_parse_pmf(int len, const char *data)
// and now we crawl through the spec. // and now we crawl through the spec.
// start with the header of "PMF",0x1A,1,0,0,0 // start with the header of "PMF",0x1A,1,0,0,0
char head[8];
if(memcmp(p, "PMF\x1A\x01\x00\x00\x00", 8)) if(memcmp(p, "PMF\x1A\x01\x00\x00\x00", 8))
{ {
fprintf(stderr, "model_load_pmf: not a valid PMF v1 file\n"); fprintf(stderr, "model_load_pmf: not a valid PMF v1 file\n");
@ -199,7 +197,7 @@ model_t *model_load_pmf(const char *fname)
int model_save_pmf(model_t *pmf, const char *fname) int model_save_pmf(model_t *pmf, const char *fname)
{ {
int i,j; int i;
FILE *fp = fopen(fname, "wb"); FILE *fp = fopen(fname, "wb");
@ -210,8 +208,6 @@ int model_save_pmf(model_t *pmf, const char *fname)
// and now we crawl through the spec. // and now we crawl through the spec.
// start with the header of "PMF",0x1A,1,0,0,0 // start with the header of "PMF",0x1A,1,0,0,0
char head[8];
fwrite("PMF\x1A\x01\x00\x00\x00", 8, 1, fp); fwrite("PMF\x1A\x01\x00\x00\x00", 8, 1, fp);
// then there's a uint32_t denoting how many body parts there are // then there's a uint32_t denoting how many body parts there are

View File

@ -18,7 +18,19 @@
#include "common.h" #include "common.h"
#ifdef WIN32 #ifdef WIN32
WSADATA windows_sucks; WSADATA wsaStartup;
#define close(x) closesocket(x)
#if _MSC_VER
int bind( SOCKET s, void* name, int namelen )
{
return bind( s, (const sockaddr*)name, namelen );
}
int setsockopt( SOCKET s, int level, int optname, void* optval, int optlen )
{
return setsockopt( s, level, optname, (const char*)optval, optlen );
}
#endif
#endif #endif
int server_sockfd_ipv4 = -1; int server_sockfd_ipv4 = -1;
@ -77,7 +89,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
if (cnt < INET_ADDRSTRLEN) if (cnt < INET_ADDRSTRLEN)
return NULL; return NULL;
p = src; p = (const uint8_t*)src;
snprintf(dst, cnt, "%u.%u.%u.%u", snprintf(dst, cnt, "%u.%u.%u.%u",
(unsigned int) (p[0] & 0xff), (unsigned int) (p[1] & 0xff), (unsigned int) (p[0] & 0xff), (unsigned int) (p[1] & 0xff),
(unsigned int) (p[2] & 0xff), (unsigned int) (p[3] & 0xff)); (unsigned int) (p[2] & 0xff), (unsigned int) (p[3] & 0xff));
@ -85,7 +97,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
if (cnt < 5*8) if (cnt < 5*8)
return NULL; return NULL;
p = src; p = (const uint8_t*)src;
snprintf(dst, cnt, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", snprintf(dst, cnt, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
(unsigned int) (p[0] & 0xff), (unsigned int) (p[1] & 0xff), (unsigned int) (p[0] & 0xff), (unsigned int) (p[1] & 0xff),
(unsigned int) (p[2] & 0xff), (unsigned int) (p[3] & 0xff), (unsigned int) (p[2] & 0xff), (unsigned int) (p[3] & 0xff),
@ -119,7 +131,7 @@ int net_packet_push(int len, const char *data, int sockfd, packet_t **head, pack
return 1; return 1;
} }
packet_t *pkt = malloc(sizeof(packet_t)+len); packet_t *pkt = (packet_t*)malloc(sizeof(packet_t)+len);
if(pkt == NULL) if(pkt == NULL)
{ {
error_perror("net_packet_new"); error_perror("net_packet_new");
@ -161,7 +173,7 @@ int net_packet_push_lua(int len, const char *data, int sockfd, packet_t **head,
int poffs = (len >= 64 ? 3 : 1); int poffs = (len >= 64 ? 3 : 1);
packet_t *pkt = malloc(sizeof(packet_t)+len+poffs); packet_t *pkt = (packet_t*)malloc(sizeof(packet_t)+len+poffs);
if(pkt == NULL) if(pkt == NULL)
{ {
error_perror("net_packet_new"); error_perror("net_packet_new");
@ -331,7 +343,7 @@ char *net_fetch_file(const char *fname, int *flen)
int buf_len = 512; int buf_len = 512;
int buf_pos = 0; int buf_pos = 0;
char *buf = malloc(buf_len+1); char *buf = (char*)malloc(buf_len+1);
// TODO: check if NULL // TODO: check if NULL
int buf_cpy; int buf_cpy;
@ -352,7 +364,7 @@ char *net_fetch_file(const char *fname, int *flen)
break; break;
buf_len += (buf_len>>1)+1; buf_len += (buf_len>>1)+1;
buf = realloc(buf, buf_len+1); buf = (char*)realloc(buf, buf_len+1);
} }
fclose(fp); fclose(fp);
@ -440,7 +452,7 @@ void net_eat_c2s(client_t *cli)
use_serialised = -1; use_serialised = -1;
break; break;
} }
map_t *map = lua_touserdata(lstate_server, -1); map_t *map = (map_t*)lua_touserdata(lstate_server, -1);
lua_pop(lstate_server, 1); lua_pop(lstate_server, 1);
other->sfetch_ubuf = map_serialise_icemap( other->sfetch_ubuf = map_serialise_icemap(
map, &(other->sfetch_ulen)); map, &(other->sfetch_ulen));
@ -493,7 +505,7 @@ void net_eat_c2s(client_t *cli)
other->sfetch_udtype = udtype; other->sfetch_udtype = udtype;
uLongf cbound = compressBound(other->sfetch_ulen); uLongf cbound = compressBound(other->sfetch_ulen);
other->sfetch_cbuf = malloc(cbound); other->sfetch_cbuf = (char*)malloc(cbound);
// TODO: check if NULL // TODO: check if NULL
if(compress((Bytef *)(other->sfetch_cbuf), &cbound, if(compress((Bytef *)(other->sfetch_cbuf), &cbound,
(Bytef *)(other->sfetch_ubuf), other->sfetch_ulen)) (Bytef *)(other->sfetch_ubuf), other->sfetch_ulen))
@ -621,7 +633,7 @@ void net_eat_s2c(client_t *cli)
//printf("clen=%i ulen=%i\n", clen, ulen); //printf("clen=%i ulen=%i\n", clen, ulen);
cli->cfetch_clen = clen; cli->cfetch_clen = clen;
cli->cfetch_ulen = ulen; cli->cfetch_ulen = ulen;
cli->cfetch_cbuf = malloc(clen); cli->cfetch_cbuf = (char*)malloc(clen);
cli->cfetch_ubuf = NULL; cli->cfetch_ubuf = NULL;
cli->cfetch_cpos = 0; cli->cfetch_cpos = 0;
// TODO: check if NULL // TODO: check if NULL
@ -632,7 +644,7 @@ void net_eat_s2c(client_t *cli)
// 0x32: // 0x32:
// file transfer end // file transfer end
//printf("transfer END\n"); //printf("transfer END\n");
cli->cfetch_ubuf = malloc(cli->cfetch_ulen); cli->cfetch_ubuf = (char*)malloc(cli->cfetch_ulen);
// TODO: check if NULL // TODO: check if NULL
uLongf dlen = cli->cfetch_ulen; uLongf dlen = cli->cfetch_ulen;
@ -832,7 +844,6 @@ void net_flush_parse_s2c(client_t *cli)
client_t *net_find_sockfd(int sockfd) client_t *net_find_sockfd(int sockfd)
{ {
int i; int i;
client_t *cli;
if(sockfd == SOCKFD_LOCAL) if(sockfd == SOCKFD_LOCAL)
{ {
@ -960,7 +971,7 @@ void net_flush_accept_one(int sockfd, struct sockaddr_storage *ss, socklen_t sle
// set connection nonblocking // set connection nonblocking
yes = 1; yes = 1;
#ifdef WIN32 #ifdef WIN32
if(ioctlsocket(sockfd,FIONBIO,(void *)&yes) == -1) { if(ioctlsocket(sockfd,FIONBIO,(u_long *)&yes) == -1) {
#else #else
if(fcntl(sockfd, F_SETFL, if(fcntl(sockfd, F_SETFL,
fcntl(sockfd, F_GETFL) | O_NONBLOCK) == -1) { fcntl(sockfd, F_GETFL) | O_NONBLOCK) == -1) {
@ -1351,7 +1362,7 @@ int net_connect(void)
int yes = 1; int yes = 1;
#ifdef WIN32 #ifdef WIN32
if(ioctlsocket(sockfd, FIONBIO, (void *)&yes)) if(ioctlsocket(sockfd, FIONBIO, (u_long *)&yes))
#else #else
if(fcntl(sockfd, F_SETFL, if(fcntl(sockfd, F_SETFL,
fcntl(sockfd, F_GETFL) | O_NONBLOCK)) fcntl(sockfd, F_GETFL) | O_NONBLOCK))
@ -1421,7 +1432,6 @@ int net_bind(void)
sa4.sin_addr.s_addr = INADDR_ANY; sa4.sin_addr.s_addr = INADDR_ANY;
int yes = 1; // who the hell uses solaris anyway int yes = 1; // who the hell uses solaris anyway
int tflags;
if(setsockopt(server_sockfd_ipv6, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes)) == -1) if(setsockopt(server_sockfd_ipv6, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes)) == -1)
{ {
perror("net_bind(reuseaddr.6)"); perror("net_bind(reuseaddr.6)");
@ -1445,7 +1455,7 @@ int net_bind(void)
perror("net_bind(listen.6)"); perror("net_bind(listen.6)");
server_sockfd_ipv6 = -1; server_sockfd_ipv6 = -1;
#ifdef WIN32 #ifdef WIN32
} else if(ioctlsocket(server_sockfd_ipv6,FIONBIO,(void *)&yes)) { } else if(ioctlsocket(server_sockfd_ipv6,FIONBIO,(u_long *)&yes)) {
#else #else
} else if(fcntl(server_sockfd_ipv6, F_SETFL, } else if(fcntl(server_sockfd_ipv6, F_SETFL,
fcntl(server_sockfd_ipv6, F_GETFL) | O_NONBLOCK)) { fcntl(server_sockfd_ipv6, F_GETFL) | O_NONBLOCK)) {
@ -1466,7 +1476,7 @@ int net_bind(void)
perror("net_bind(listen.4)"); perror("net_bind(listen.4)");
server_sockfd_ipv4 = -1; server_sockfd_ipv4 = -1;
#ifdef WIN32 #ifdef WIN32
} else if(ioctlsocket(server_sockfd_ipv4,FIONBIO,(void *)&yes)) { } else if(ioctlsocket(server_sockfd_ipv4,FIONBIO,(u_long *)&yes)) {
#else #else
} else if(fcntl(server_sockfd_ipv4, F_SETFL, } else if(fcntl(server_sockfd_ipv4, F_SETFL,
fcntl(server_sockfd_ipv4, F_GETFL) | O_NONBLOCK)) { fcntl(server_sockfd_ipv4, F_GETFL) | O_NONBLOCK)) {
@ -1507,7 +1517,7 @@ int net_init(void)
#ifdef WIN32 #ifdef WIN32
// complete hackjob // complete hackjob
if(WSAStartup(MAKEWORD(2,0), &windows_sucks) != 0) if(WSAStartup(MAKEWORD(2,0), &wsaStartup) != 0)
{ {
fprintf(stderr, "net_init: WSAStartup failed\n"); fprintf(stderr, "net_init: WSAStartup failed\n");
return 1; return 1;

View File

@ -859,7 +859,7 @@ void render_vxl_redraw(camera_t *camera, map_t *map)
return; return;
} }
int i,x,y,z; int i;
// stash stuff in globals to prevent spamming the stack too much // stash stuff in globals to prevent spamming the stack too much
// (and in turn thrashing the cache) // (and in turn thrashing the cache)
@ -896,7 +896,7 @@ void render_vxl_redraw(camera_t *camera, map_t *map)
if(rayc_mark_size != markbase) if(rayc_mark_size != markbase)
{ {
rayc_mark_size = markbase; rayc_mark_size = markbase;
rayc_mark = realloc(rayc_mark, rayc_mark_size*sizeof(int)); rayc_mark = (int*)realloc(rayc_mark, rayc_mark_size*sizeof(int));
#ifdef RENDER_CUBES_MULTITHREADED #ifdef RENDER_CUBES_MULTITHREADED
rayc_stack_len = realloc(rayc_stack_len, rayc_mark_size*8*sizeof(int)); rayc_stack_len = realloc(rayc_stack_len, rayc_mark_size*8*sizeof(int));
rayc_stack_ordlen = realloc(rayc_stack_ordlen, rayc_mark_size*8*sizeof(int)); rayc_stack_ordlen = realloc(rayc_stack_ordlen, rayc_mark_size*8*sizeof(int));
@ -906,7 +906,7 @@ void render_vxl_redraw(camera_t *camera, map_t *map)
if(rayc_block_size != blockbase) if(rayc_block_size != blockbase)
{ {
rayc_block_size = blockbase; rayc_block_size = blockbase;
rayc_block = realloc(rayc_block, rayc_block_size*sizeof(rayblock_t)); rayc_block = (rayblock_t*)realloc(rayc_block, rayc_block_size*sizeof(rayblock_t));
} }
} }
@ -1284,7 +1284,7 @@ void render_cubemap_edge(
int x1, int y1, float z1, float u1, float v1, int x1, int y1, float z1, float u1, float v1,
int x2, int y2, float z2, float u2, float v2) int x2, int y2, float z2, float u2, float v2)
{ {
int x,y; int y;
// if out of Y range, drop out early. // if out of Y range, drop out early.
if(y1 < 0 && y2 < 0) if(y1 < 0 && y2 < 0)
@ -1577,7 +1577,7 @@ void render_cubemap_new(uint32_t *pixels, int width, int height, int pitch, came
free(elist); free(elist);
elist_len = height; elist_len = height;
elist = malloc(sizeof(edgebit_t)*elist_len); elist = (edgebit_t*)malloc(sizeof(edgebit_t)*elist_len);
} }
// do each face // do each face
@ -1593,7 +1593,7 @@ void render_cubemap_new(uint32_t *pixels, int width, int height, int pitch, came
void render_cubemap(uint32_t *pixels, int width, int height, int pitch, camera_t *camera, map_t *map) void render_cubemap(uint32_t *pixels, int width, int height, int pitch, camera_t *camera, map_t *map)
{ {
int x,y,z; int x,y;
// stash stuff in globals to prevent spamming the stack too much // stash stuff in globals to prevent spamming the stack too much
// (and in turn thrashing the cache) // (and in turn thrashing the cache)
@ -1880,8 +1880,8 @@ int render_init(int width, int height)
// allocate cubemaps // allocate cubemaps
for(i = 0; i < CM_MAX; i++) for(i = 0; i < CM_MAX; i++)
{ {
cubemap_color[i] = malloc(size*size*4); cubemap_color[i] = (uint32_t*)malloc(size*size*4);
cubemap_depth[i] = malloc(size*size*4); cubemap_depth[i] = (float*)malloc(size*size*4);
if(cubemap_color[i] == NULL || cubemap_depth[i] == NULL) if(cubemap_color[i] == NULL || cubemap_depth[i] == NULL)
{ {
// Can't allocate :. Can't continue // Can't allocate :. Can't continue
@ -1913,7 +1913,7 @@ int render_init(int width, int height)
} }
// allocate space for depth buffer // allocate space for depth buffer
dbuf = malloc(width*height*sizeof(float)); dbuf = (float*)malloc(width*height*sizeof(float));
// TODO: check if NULL // TODO: check if NULL
return 0; return 0;

View File

@ -276,7 +276,7 @@ wav_t *wav_parse(char *buf, int len)
int datalen_smps = datalen/fmt.blkalign; int datalen_smps = datalen/fmt.blkalign;
wav_t *wav = malloc(sizeof(wav_t)*datalen_smps); wav_t *wav = (wav_t*)malloc(sizeof(wav_t)*datalen_smps);
wav->udtype = UD_WAV; wav->udtype = UD_WAV;
wav->refcount = 1; wav->refcount = 1;
wav->len = datalen_smps; wav->len = datalen_smps;