mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 17:22:12 +00:00
Merge branch 'master' of http://git.magicalgirl.moe/STJr/SRB2Internal.git into s_skinprovements
This commit is contained in:
commit
c9227dfbed
30 changed files with 428 additions and 241 deletions
33
SRB2.cbp
33
SRB2.cbp
|
@ -2815,6 +2815,39 @@ HW3SOUND for 3D hardware sound support
|
|||
<Option target="Debug Mingw64/DirectX" />
|
||||
<Option target="Release Mingw64/DirectX" />
|
||||
</Unit>
|
||||
<Unit filename="src/m_aatree.c">
|
||||
<Option compilerVar="CC" />
|
||||
<Option target="Debug Native/SDL" />
|
||||
<Option target="Release Native/SDL" />
|
||||
<Option target="Debug Mingw/SDL" />
|
||||
<Option target="Release Mingw/SDL" />
|
||||
<Option target="Debug Mingw/DirectX" />
|
||||
<Option target="Release Mingw/DirectX" />
|
||||
<Option target="Debug Any/Dummy" />
|
||||
<Option target="Release Any/Dummy" />
|
||||
<Option target="Debug Linux/SDL" />
|
||||
<Option target="Release Linux/SDL" />
|
||||
<Option target="Debug Mingw64/SDL" />
|
||||
<Option target="Release Mingw64/SDL" />
|
||||
<Option target="Debug Mingw64/DirectX" />
|
||||
<Option target="Release Mingw64/DirectX" />
|
||||
</Unit>
|
||||
<Unit filename="src/m_aatree.h">
|
||||
<Option target="Debug Native/SDL" />
|
||||
<Option target="Release Native/SDL" />
|
||||
<Option target="Debug Mingw/SDL" />
|
||||
<Option target="Release Mingw/SDL" />
|
||||
<Option target="Debug Mingw/DirectX" />
|
||||
<Option target="Release Mingw/DirectX" />
|
||||
<Option target="Debug Any/Dummy" />
|
||||
<Option target="Release Any/Dummy" />
|
||||
<Option target="Debug Linux/SDL" />
|
||||
<Option target="Release Linux/SDL" />
|
||||
<Option target="Debug Mingw64/SDL" />
|
||||
<Option target="Release Mingw64/SDL" />
|
||||
<Option target="Debug Mingw64/DirectX" />
|
||||
<Option target="Release Mingw64/DirectX" />
|
||||
</Unit>
|
||||
<Unit filename="src/m_anigif.c">
|
||||
<Option compilerVar="CC" />
|
||||
<Option target="Debug Native/SDL" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
version: 2.1.14.{branch}-{build}
|
||||
version: 2.1.16.{branch}-{build}
|
||||
os: MinGW
|
||||
|
||||
environment:
|
||||
|
|
|
@ -22,6 +22,7 @@ set(SRB2_CORE_SOURCES
|
|||
i_tcp.c
|
||||
info.c
|
||||
lzf.c
|
||||
m_aatree.c
|
||||
m_anigif.c
|
||||
m_argv.c
|
||||
m_bbox.c
|
||||
|
@ -83,6 +84,7 @@ set(SRB2_CORE_HEADERS
|
|||
info.h
|
||||
keys.h
|
||||
lzf.h
|
||||
m_aatree.h
|
||||
m_anigif.h
|
||||
m_argv.h
|
||||
m_bbox.h
|
||||
|
|
14
src/Makefile
14
src/Makefile
|
@ -189,6 +189,10 @@ ifdef FREEBSD
|
|||
UNIXCOMMON=1
|
||||
endif
|
||||
|
||||
ifdef MACOSX
|
||||
UNIXCOMMON=1
|
||||
endif
|
||||
|
||||
ifdef NDS
|
||||
NOPNG=1
|
||||
NONET=1
|
||||
|
@ -429,6 +433,7 @@ OBJS:=$(i_main_o) \
|
|||
$(OBJDIR)/hu_stuff.o \
|
||||
$(OBJDIR)/y_inter.o \
|
||||
$(OBJDIR)/st_stuff.o \
|
||||
$(OBJDIR)/m_aatree.o \
|
||||
$(OBJDIR)/m_anigif.o \
|
||||
$(OBJDIR)/m_argv.o \
|
||||
$(OBJDIR)/m_bbox.o \
|
||||
|
@ -593,11 +598,15 @@ ifndef WINDOWSHELL
|
|||
-$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt
|
||||
endif
|
||||
endif
|
||||
|
||||
# mac os x lsdlsrb2 does not like objcopy
|
||||
ifndef MACOSX
|
||||
ifndef PSP
|
||||
$(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME)
|
||||
$(OBJCOPY) --strip-debug $(BIN)/$(EXENAME)
|
||||
-$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME)
|
||||
endif
|
||||
endif
|
||||
ifndef NOUPX
|
||||
-$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME)
|
||||
endif
|
||||
|
@ -745,6 +754,11 @@ $(OBJDIR)/%.o: %.c
|
|||
$(OBJDIR)/%.o: $(INTERFACE)/%.c
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
|
||||
|
||||
ifdef MACOSX
|
||||
$(OBJDIR)/%.o: sdl/macosx/%.c
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%.o: hardware/%.c
|
||||
$(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -406,6 +406,15 @@ else
|
|||
WINDRES=windres
|
||||
endif
|
||||
|
||||
# because Apple screws with us on this
|
||||
# need to get bintools from homebrew
|
||||
ifdef MACOSX
|
||||
CC=clang
|
||||
CXX=clang
|
||||
OBJCOPY=gobjcopy
|
||||
OBJDUMP=gobjdump
|
||||
endif
|
||||
|
||||
OBJDUMP_OPTS?=--wide --source --line-numbers
|
||||
LD=$(CC)
|
||||
|
||||
|
|
|
@ -650,6 +650,22 @@ static void readfreeslots(MYFILE *f)
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (fastcmp(type, "SPR2"))
|
||||
{
|
||||
// Search if we already have an SPR2 by that name...
|
||||
for (i = SPR2_FIRSTFREESLOT; i < (int)free_spr2; i++)
|
||||
if (memcmp(spr2names[i],word,4) == 0)
|
||||
break;
|
||||
// We found it? (Two mods using the same SPR2 name?) Then don't allocate another one.
|
||||
if (i < (int)free_spr2)
|
||||
continue;
|
||||
// Copy in the spr2 name and increment free_spr2.
|
||||
if (free_spr2 < NUMPLAYERSPRITES) {
|
||||
strncpy(spr2names[free_spr2],word,4);
|
||||
spr2names[free_spr2++][4] = 0;
|
||||
} else
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n");
|
||||
}
|
||||
else
|
||||
deh_warning("Freeslots: unknown enum class '%s' for '%s_%s'", type, type, word);
|
||||
}
|
||||
|
@ -7879,7 +7895,7 @@ static inline int lib_freeslot(lua_State *L)
|
|||
lua_pushinteger(L, sfx);
|
||||
r++;
|
||||
} else
|
||||
return r;
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free SFX slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "SPR"))
|
||||
{
|
||||
|
@ -7906,7 +7922,7 @@ static inline int lib_freeslot(lua_State *L)
|
|||
break;
|
||||
}
|
||||
if (j > SPR_LASTFREESLOT)
|
||||
return r;
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free sprite slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "S"))
|
||||
{
|
||||
|
@ -7921,7 +7937,7 @@ static inline int lib_freeslot(lua_State *L)
|
|||
break;
|
||||
}
|
||||
if (i == NUMSTATEFREESLOTS)
|
||||
return r;
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "MT"))
|
||||
{
|
||||
|
@ -7936,7 +7952,26 @@ static inline int lib_freeslot(lua_State *L)
|
|||
break;
|
||||
}
|
||||
if (i == NUMMOBJFREESLOTS)
|
||||
return r;
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n");
|
||||
}
|
||||
else if (fastcmp(type, "SPR2"))
|
||||
{
|
||||
// Search if we already have an SPR2 by that name...
|
||||
enum playersprite i;
|
||||
for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++)
|
||||
if (memcmp(spr2names[i],word,4) == 0)
|
||||
break;
|
||||
// We don't, so allocate a new one.
|
||||
if (i >= free_spr2) {
|
||||
if (free_spr2 < NUMPLAYERSPRITES)
|
||||
{
|
||||
CONS_Printf("Sprite SPR2_%s allocated.\n",word);
|
||||
strncpy(spr2names[free_spr2],word,4);
|
||||
spr2names[free_spr2++][4] = 0;
|
||||
} else
|
||||
CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n");
|
||||
}
|
||||
r++;
|
||||
}
|
||||
Z_Free(s);
|
||||
lua_remove(L, 1);
|
||||
|
@ -8103,7 +8138,7 @@ static inline int lib_getenum(lua_State *L)
|
|||
}
|
||||
else if (fastncmp("SPR2_",word,4)) {
|
||||
p = word+5;
|
||||
for (i = 0; i < NUMPLAYERSPRITES; i++)
|
||||
for (i = 0; i < (fixed_t)free_spr2; i++)
|
||||
if (!spr2names[i][4])
|
||||
{
|
||||
// special 3-char cases, e.g. SPR2_RUN
|
||||
|
|
|
@ -92,7 +92,7 @@ typedef long ssize_t;
|
|||
#endif
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
#define DIRECTFULLSCREEN
|
||||
#define DIRECTFULLSCREEN 1
|
||||
#define DEBUG_LOG
|
||||
#define NOIPX
|
||||
#endif
|
||||
|
|
|
@ -108,6 +108,7 @@ char spr2names[NUMPLAYERSPRITES][5] =
|
|||
"SRID",
|
||||
"SFLT"
|
||||
};
|
||||
enum playersprite free_spr2 = SPR2_FIRSTFREESLOT;
|
||||
|
||||
// Doesn't work with g++, needs actionf_p1 (don't modify this comment)
|
||||
state_t states[NUMSTATES] =
|
||||
|
|
|
@ -631,6 +631,8 @@ enum playersprite
|
|||
SPR2_SRID,
|
||||
SPR2_SFLT,
|
||||
|
||||
SPR2_FIRSTFREESLOT,
|
||||
SPR2_LASTFREESLOT = SPR2_FIRSTFREESLOT + NUMSPRITEFREESLOTS - 1,
|
||||
NUMPLAYERSPRITES
|
||||
};
|
||||
|
||||
|
@ -3053,8 +3055,9 @@ typedef struct
|
|||
|
||||
extern state_t states[NUMSTATES];
|
||||
extern char sprnames[NUMSPRITES + 1][5];
|
||||
char spr2names[NUMPLAYERSPRITES][5];
|
||||
extern char spr2names[NUMPLAYERSPRITES][5];
|
||||
extern state_t *astate;
|
||||
extern enum playersprite free_spr2;
|
||||
|
||||
typedef enum mobj_type
|
||||
{
|
||||
|
|
|
@ -105,7 +105,7 @@ static int lib_getSpr2name(lua_State *L)
|
|||
if (lua_isnumber(L, 1))
|
||||
{
|
||||
i = lua_tonumber(L, 1);
|
||||
if (i > NUMPLAYERSPRITES)
|
||||
if (i >= free_spr2)
|
||||
return 0;
|
||||
lua_pushlstring(L, spr2names[i], 4);
|
||||
return 1;
|
||||
|
@ -113,7 +113,7 @@ static int lib_getSpr2name(lua_State *L)
|
|||
else if (lua_isstring(L, 1))
|
||||
{
|
||||
const char *name = lua_tostring(L, 1);
|
||||
for (i = 0; i < NUMPLAYERSPRITES; i++)
|
||||
for (i = 0; i < free_spr2; i++)
|
||||
if (fastcmp(name, spr2names[i]))
|
||||
{
|
||||
lua_pushinteger(L, i);
|
||||
|
@ -125,7 +125,7 @@ static int lib_getSpr2name(lua_State *L)
|
|||
|
||||
static int lib_spr2namelen(lua_State *L)
|
||||
{
|
||||
lua_pushinteger(L, NUMPLAYERSPRITES);
|
||||
lua_pushinteger(L, free_spr2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,11 @@
|
|||
* Unconditionally aligning does not cost very much, so do it if unsure
|
||||
*/
|
||||
#ifndef STRICT_ALIGN
|
||||
# define STRICT_ALIGN !(defined(__i386) || defined (__amd64)) || defined (__clang__)
|
||||
#if !(defined(__i386) || defined (__amd64)) || defined (__clang__)
|
||||
#define STRICT_ALIGN 1
|
||||
#else
|
||||
#define STRICT_ALIGN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
167
src/m_aatree.c
Normal file
167
src/m_aatree.c
Normal file
|
@ -0,0 +1,167 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2016 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file m_aatree.h
|
||||
/// \brief AA trees code
|
||||
|
||||
#include "m_aatree.h"
|
||||
#include "z_zone.h"
|
||||
|
||||
// A partial implementation of AA trees,
|
||||
// according to the algorithms given on Wikipedia.
|
||||
// http://en.wikipedia.org/wiki/AA_tree
|
||||
|
||||
typedef struct aatree_node_s
|
||||
{
|
||||
INT32 level;
|
||||
INT32 key;
|
||||
void* value;
|
||||
|
||||
struct aatree_node_s *left, *right;
|
||||
} aatree_node_t;
|
||||
|
||||
struct aatree_s
|
||||
{
|
||||
aatree_node_t *root;
|
||||
UINT32 flags;
|
||||
};
|
||||
|
||||
aatree_t *M_AATreeAlloc(UINT32 flags)
|
||||
{
|
||||
aatree_t *aatree = Z_Malloc(sizeof (aatree_t), PU_STATIC, NULL);
|
||||
aatree->root = NULL;
|
||||
aatree->flags = flags;
|
||||
return aatree;
|
||||
}
|
||||
|
||||
static void M_AATreeFree_Node(aatree_node_t *node)
|
||||
{
|
||||
if (node->left) M_AATreeFree_Node(node->left);
|
||||
if (node->right) M_AATreeFree_Node(node->right);
|
||||
Z_Free(node);
|
||||
}
|
||||
|
||||
void M_AATreeFree(aatree_t *aatree)
|
||||
{
|
||||
if (aatree->root)
|
||||
M_AATreeFree_Node(aatree->root);
|
||||
|
||||
Z_Free(aatree);
|
||||
}
|
||||
|
||||
static aatree_node_t *M_AATreeSkew(aatree_node_t *node)
|
||||
{
|
||||
if (node && node->left && node->left->level == node->level)
|
||||
{
|
||||
// Not allowed: horizontal left-link. Reverse the
|
||||
// horizontal link and hook the orphan back in.
|
||||
aatree_node_t *oldleft = node->left;
|
||||
node->left = oldleft->right;
|
||||
oldleft->right = node;
|
||||
|
||||
return oldleft;
|
||||
}
|
||||
|
||||
// No change needed.
|
||||
return node;
|
||||
}
|
||||
|
||||
static aatree_node_t *M_AATreeSplit(aatree_node_t *node)
|
||||
{
|
||||
if (node && node->right && node->right->right && node->level == node->right->right->level)
|
||||
{
|
||||
// Not allowed: two consecutive horizontal right-links.
|
||||
// The middle one becomes the new root at this point,
|
||||
// with suitable adjustments below.
|
||||
|
||||
aatree_node_t *oldright = node->right;
|
||||
node->right = oldright->left;
|
||||
oldright->left = node;
|
||||
oldright->level++;
|
||||
|
||||
return oldright;
|
||||
}
|
||||
|
||||
// No change needed.
|
||||
return node;
|
||||
}
|
||||
|
||||
static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 key, void* value)
|
||||
{
|
||||
if (!node)
|
||||
{
|
||||
// Nothing here, so just add where we are
|
||||
|
||||
node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL);
|
||||
node->level = 1;
|
||||
node->key = key;
|
||||
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
|
||||
else node->value = value;
|
||||
node->left = node->right = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key < node->key)
|
||||
node->left = M_AATreeSet_Node(node->left, flags, key, value);
|
||||
else if (key > node->key)
|
||||
node->right = M_AATreeSet_Node(node->right, flags, key, value);
|
||||
else
|
||||
{
|
||||
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
|
||||
else node->value = value;
|
||||
}
|
||||
|
||||
node = M_AATreeSkew(node);
|
||||
node = M_AATreeSplit(node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value)
|
||||
{
|
||||
aatree->root = M_AATreeSet_Node(aatree->root, aatree->flags, key, value);
|
||||
}
|
||||
|
||||
// Caveat: we don't distinguish between nodes that don't exists
|
||||
// and nodes with value == NULL.
|
||||
static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key)
|
||||
{
|
||||
if (node)
|
||||
{
|
||||
if (node->key == key)
|
||||
return node->value;
|
||||
else if(node->key < key)
|
||||
return M_AATreeGet_Node(node->right, key);
|
||||
else
|
||||
return M_AATreeGet_Node(node->left, key);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *M_AATreeGet(aatree_t *aatree, INT32 key)
|
||||
{
|
||||
return M_AATreeGet_Node(aatree->root, key);
|
||||
}
|
||||
|
||||
|
||||
static void M_AATreeIterate_Node(aatree_node_t *node, aatree_iter_t callback)
|
||||
{
|
||||
if (node->left) M_AATreeIterate_Node(node->left, callback);
|
||||
callback(node->key, node->value);
|
||||
if (node->right) M_AATreeIterate_Node(node->right, callback);
|
||||
}
|
||||
|
||||
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback)
|
||||
{
|
||||
if (aatree->root)
|
||||
M_AATreeIterate_Node(aatree->root, callback);
|
||||
}
|
31
src/m_aatree.h
Normal file
31
src/m_aatree.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2016 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file m_aatree.h
|
||||
/// \brief AA trees code
|
||||
|
||||
#ifndef __M_AATREE__
|
||||
#define __M_AATREE__
|
||||
|
||||
#include "doomtype.h"
|
||||
|
||||
// Flags for AA trees.
|
||||
#define AATREE_ZUSER 1 // Treat values as z_zone-allocated blocks and set their user fields
|
||||
|
||||
typedef struct aatree_s aatree_t;
|
||||
typedef void (*aatree_iter_t)(INT32 key, void *value);
|
||||
|
||||
aatree_t *M_AATreeAlloc(UINT32 flags);
|
||||
void M_AATreeFree(aatree_t *aatree);
|
||||
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value);
|
||||
void *M_AATreeGet(aatree_t *aatree, INT32 key);
|
||||
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback);
|
||||
|
||||
#endif
|
155
src/m_misc.c
155
src/m_misc.c
|
@ -2323,158 +2323,3 @@ void M_SetupMemcpy(void)
|
|||
M_Memcpy = cpu_cpy;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// A partial implementation of AA trees,
|
||||
// according to the algorithms given on Wikipedia.
|
||||
// http://en.wikipedia.org/wiki/AA_tree
|
||||
|
||||
|
||||
|
||||
typedef struct aatree_node_s
|
||||
{
|
||||
INT32 level;
|
||||
INT32 key;
|
||||
void* value;
|
||||
|
||||
struct aatree_node_s *left, *right;
|
||||
} aatree_node_t;
|
||||
|
||||
struct aatree_s
|
||||
{
|
||||
aatree_node_t *root;
|
||||
UINT32 flags;
|
||||
};
|
||||
|
||||
aatree_t *M_AATreeAlloc(UINT32 flags)
|
||||
{
|
||||
aatree_t *aatree = Z_Malloc(sizeof (aatree_t), PU_STATIC, NULL);
|
||||
aatree->root = NULL;
|
||||
aatree->flags = flags;
|
||||
return aatree;
|
||||
}
|
||||
|
||||
static void M_AATreeFree_Node(aatree_node_t *node)
|
||||
{
|
||||
if (node->left) M_AATreeFree_Node(node->left);
|
||||
if (node->right) M_AATreeFree_Node(node->right);
|
||||
Z_Free(node);
|
||||
}
|
||||
|
||||
void M_AATreeFree(aatree_t *aatree)
|
||||
{
|
||||
if (aatree->root)
|
||||
M_AATreeFree_Node(aatree->root);
|
||||
|
||||
Z_Free(aatree);
|
||||
}
|
||||
|
||||
static aatree_node_t *M_AATreeSkew(aatree_node_t *node)
|
||||
{
|
||||
if (node && node->left && node->left->level == node->level)
|
||||
{
|
||||
// Not allowed: horizontal left-link. Reverse the
|
||||
// horizontal link and hook the orphan back in.
|
||||
aatree_node_t *oldleft = node->left;
|
||||
node->left = oldleft->right;
|
||||
oldleft->right = node;
|
||||
|
||||
return oldleft;
|
||||
}
|
||||
|
||||
// No change needed.
|
||||
return node;
|
||||
}
|
||||
|
||||
static aatree_node_t *M_AATreeSplit(aatree_node_t *node)
|
||||
{
|
||||
if (node && node->right && node->right->right && node->level == node->right->right->level)
|
||||
{
|
||||
// Not allowed: two consecutive horizontal right-links.
|
||||
// The middle one becomes the new root at this point,
|
||||
// with suitable adjustments below.
|
||||
|
||||
aatree_node_t *oldright = node->right;
|
||||
node->right = oldright->left;
|
||||
oldright->left = node;
|
||||
oldright->level++;
|
||||
|
||||
return oldright;
|
||||
}
|
||||
|
||||
// No change needed.
|
||||
return node;
|
||||
}
|
||||
|
||||
static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 key, void* value)
|
||||
{
|
||||
if (!node)
|
||||
{
|
||||
// Nothing here, so just add where we are
|
||||
|
||||
node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL);
|
||||
node->level = 1;
|
||||
node->key = key;
|
||||
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
|
||||
else node->value = value;
|
||||
node->left = node->right = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key < node->key)
|
||||
node->left = M_AATreeSet_Node(node->left, flags, key, value);
|
||||
else if (key > node->key)
|
||||
node->right = M_AATreeSet_Node(node->right, flags, key, value);
|
||||
else
|
||||
{
|
||||
if (value && (flags & AATREE_ZUSER)) Z_SetUser(value, &node->value);
|
||||
else node->value = value;
|
||||
}
|
||||
|
||||
node = M_AATreeSkew(node);
|
||||
node = M_AATreeSplit(node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value)
|
||||
{
|
||||
aatree->root = M_AATreeSet_Node(aatree->root, aatree->flags, key, value);
|
||||
}
|
||||
|
||||
// Caveat: we don't distinguish between nodes that don't exists
|
||||
// and nodes with value == NULL.
|
||||
static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key)
|
||||
{
|
||||
if (node)
|
||||
{
|
||||
if (node->key == key)
|
||||
return node->value;
|
||||
else if(node->key < key)
|
||||
return M_AATreeGet_Node(node->right, key);
|
||||
else
|
||||
return M_AATreeGet_Node(node->left, key);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *M_AATreeGet(aatree_t *aatree, INT32 key)
|
||||
{
|
||||
return M_AATreeGet_Node(aatree->root, key);
|
||||
}
|
||||
|
||||
|
||||
static void M_AATreeIterate_Node(aatree_node_t *node, aatree_iter_t callback)
|
||||
{
|
||||
if (node->left) M_AATreeIterate_Node(node->left, callback);
|
||||
callback(node->key, node->value);
|
||||
if (node->right) M_AATreeIterate_Node(node->right, callback);
|
||||
}
|
||||
|
||||
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback)
|
||||
{
|
||||
if (aatree->root)
|
||||
M_AATreeIterate_Node(aatree->root, callback);
|
||||
}
|
||||
|
|
13
src/m_misc.h
13
src/m_misc.h
|
@ -96,19 +96,6 @@ void M_SetupMemcpy(void);
|
|||
// counting bits, for weapon ammo code, usually
|
||||
FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);
|
||||
|
||||
// Flags for AA trees.
|
||||
#define AATREE_ZUSER 1 // Treat values as z_zone-allocated blocks and set their user fields
|
||||
|
||||
typedef struct aatree_s aatree_t;
|
||||
typedef void (*aatree_iter_t)(INT32 key, void *value);
|
||||
|
||||
aatree_t *M_AATreeAlloc(UINT32 flags);
|
||||
void M_AATreeFree(aatree_t *aatree);
|
||||
void M_AATreeSet(aatree_t *aatree, INT32 key, void* value);
|
||||
void *M_AATreeGet(aatree_t *aatree, INT32 key);
|
||||
void M_AATreeIterate(aatree_t *aatree, aatree_iter_t callback);
|
||||
|
||||
// Nasty cyclic dependency workaround. This must come after aatree stuff.
|
||||
#include "w_wad.h"
|
||||
extern char configfile[MAX_WADPATH];
|
||||
|
||||
|
|
14
src/p_map.c
14
src/p_map.c
|
@ -129,6 +129,10 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef ESLOPE
|
||||
object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you.
|
||||
#endif
|
||||
|
||||
object->eflags |= MFE_SPRUNG; // apply this flag asap!
|
||||
spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify
|
||||
|
||||
|
@ -232,20 +236,24 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
|
|||
if (p && object->state == &states[object->info->painstate]) // can't use fans and gas jets when player is in pain!
|
||||
return;
|
||||
|
||||
// is object below thruster's position? if not, calculate distance between their bottoms
|
||||
// is object's top below thruster's position? if not, calculate distance between their bottoms
|
||||
if (spring->eflags & MFE_VERTICALFLIP)
|
||||
{
|
||||
if (object->z + object->height > spring->z + spring->height)
|
||||
if (object->z > spring->z + spring->height)
|
||||
return;
|
||||
zdist = (spring->z + spring->height) - (object->z + object->height);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (object->z < spring->z)
|
||||
if (object->z + object->height < spring->z)
|
||||
return;
|
||||
zdist = object->z - spring->z;
|
||||
}
|
||||
|
||||
#ifdef ESLOPE
|
||||
object->standingslope = NULL; // No launching off at silly angles for you.
|
||||
#endif
|
||||
|
||||
switch (spring->type)
|
||||
{
|
||||
case MT_FAN: // fan
|
||||
|
|
|
@ -2653,9 +2653,9 @@ static boolean P_ZMovement(mobj_t *mo)
|
|||
|
||||
#ifdef ESLOPE
|
||||
P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly
|
||||
if ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) {
|
||||
if (((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) && (mo->type != MT_STEAM))
|
||||
{
|
||||
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope;
|
||||
|
||||
P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope);
|
||||
}
|
||||
#endif
|
||||
|
@ -2809,7 +2809,7 @@ static boolean P_ZMovement(mobj_t *mo)
|
|||
mom.z = tmfloorthing->momz;
|
||||
|
||||
#ifdef ESLOPE
|
||||
if (mo->standingslope) {
|
||||
if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above.
|
||||
P_QuantizeMomentumToSlope(&mom, mo->standingslope);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct
|
|||
{
|
||||
// Block origin (always UL), which has already accounted for the internal origin of the patch.
|
||||
INT16 originx, originy;
|
||||
INT16 wad, lump;
|
||||
UINT16 wad, lump;
|
||||
} texpatch_t;
|
||||
|
||||
// A maptexturedef_t describes a rectangular texture,
|
||||
|
|
|
@ -874,9 +874,9 @@ void R_DrawTiltedSplat_8(void)
|
|||
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
|
||||
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
||||
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = val;
|
||||
*dest = colormap[val];
|
||||
dest++;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
|
@ -913,9 +913,9 @@ void R_DrawTiltedSplat_8(void)
|
|||
for (i = SPANSIZE-1; i >= 0; i--)
|
||||
{
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
||||
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = val;
|
||||
*dest = colormap[val];
|
||||
dest++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
|
@ -931,9 +931,9 @@ void R_DrawTiltedSplat_8(void)
|
|||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
||||
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = val;
|
||||
*dest = colormap[val];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -954,9 +954,9 @@ void R_DrawTiltedSplat_8(void)
|
|||
for (; width != 0; width--)
|
||||
{
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
val = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
||||
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = val;
|
||||
*dest = colormap[val];
|
||||
dest++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
|
@ -1124,49 +1124,49 @@ void R_DrawTranslucentSplat_8 (void)
|
|||
// need!
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[0])];
|
||||
dest[0] = colormap[*(ds_transmap + (val << 8) + dest[0])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[1])];
|
||||
dest[1] = colormap[*(ds_transmap + (val << 8) + dest[1])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[2])];
|
||||
dest[2] = colormap[*(ds_transmap + (val << 8) + dest[2])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[3])];
|
||||
dest[3] = colormap[*(ds_transmap + (val << 8) + dest[3])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[4])];
|
||||
dest[4] = colormap[*(ds_transmap + (val << 8) + dest[4])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[5])];
|
||||
dest[5] = colormap[*(ds_transmap + (val << 8) + dest[5])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[6])];
|
||||
dest[6] = colormap[*(ds_transmap + (val << 8) + dest[6])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + dest[7])];
|
||||
dest[7] = colormap[*(ds_transmap + (val << 8) + dest[7])];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
|
@ -1175,9 +1175,9 @@ void R_DrawTranslucentSplat_8 (void)
|
|||
}
|
||||
while (count--)
|
||||
{
|
||||
val =colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dest)];
|
||||
*dest = colormap[*(ds_transmap + (val << 8) + *dest)];
|
||||
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
|
|
|
@ -919,9 +919,9 @@ void R_SkyboxFrame(player_t *player)
|
|||
}
|
||||
}
|
||||
if (mh->skybox_scalez > 0)
|
||||
viewz += player->awayviewmobj->z / mh->skybox_scalez;
|
||||
viewz += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez;
|
||||
else if (mh->skybox_scalez < 0)
|
||||
viewz += player->awayviewmobj->z * -mh->skybox_scalez;
|
||||
viewz += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez;
|
||||
}
|
||||
else if (thiscam->chase)
|
||||
{
|
||||
|
@ -966,9 +966,9 @@ void R_SkyboxFrame(player_t *player)
|
|||
}
|
||||
}
|
||||
if (mh->skybox_scalez > 0)
|
||||
viewz += thiscam->z / mh->skybox_scalez;
|
||||
viewz += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez;
|
||||
else if (mh->skybox_scalez < 0)
|
||||
viewz += thiscam->z * -mh->skybox_scalez;
|
||||
viewz += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1488,7 +1488,7 @@ static void R_RenderSegLoop (void)
|
|||
{
|
||||
// note: don't use min/max macros, since casting from INT32 to INT16 is involved here
|
||||
if (markceiling)
|
||||
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||
ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||
if (markfloor)
|
||||
floorclip[rw_x] = (yh < viewheight) ? ((yh < -1) ? -1 : (INT16)((INT16)yh + 1)) : (INT16)viewheight;
|
||||
}
|
||||
|
@ -1523,10 +1523,10 @@ static void R_RenderSegLoop (void)
|
|||
ceilingclip[rw_x] = -1;
|
||||
}
|
||||
else
|
||||
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||
ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||
}
|
||||
else if (markceiling) // no top wall
|
||||
ceilingclip[rw_x] = (yh >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||
ceilingclip[rw_x] = (yl >= 0) ? ((yl > viewheight) ? (INT16)viewheight : (INT16)((INT16)yl - 1)) : -1;
|
||||
|
||||
if (bottomtexture)
|
||||
{
|
||||
|
|
|
@ -2719,7 +2719,7 @@ next_token:
|
|||
if (z < lastlump) lastlump = z;
|
||||
|
||||
// load all sprite sets we are aware of.
|
||||
for (sprite2 = 0; sprite2 < NUMPLAYERSPRITES; sprite2++)
|
||||
for (sprite2 = 0; sprite2 < free_spr2; sprite2++)
|
||||
R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, lump, lastlump);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,15 @@ ifdef FREEBSD
|
|||
LIBS+=-lipx -lkvm
|
||||
endif
|
||||
|
||||
#
|
||||
#here is Mac OS X
|
||||
#
|
||||
ifdef MACOSX
|
||||
OBJS+=$(OBJDIR)/mac_resources.o
|
||||
OBJS+=$(OBJDIR)/mac_alert.o
|
||||
LIBS+=-framework CoreFoundation
|
||||
endif
|
||||
|
||||
#
|
||||
#here is GP2x (arm-gp2x-linux)
|
||||
#
|
||||
|
|
|
@ -167,6 +167,7 @@
|
|||
<ClInclude Include="..\lzf.h" />
|
||||
<ClInclude Include="..\md5.h" />
|
||||
<ClInclude Include="..\mserv.h" />
|
||||
<ClInclude Include="..\m_aatree.h" />
|
||||
<ClInclude Include="..\m_anigif.h" />
|
||||
<ClInclude Include="..\m_argv.h" />
|
||||
<ClInclude Include="..\m_bbox.h" />
|
||||
|
@ -308,6 +309,7 @@
|
|||
<ClCompile Include="..\lzf.c" />
|
||||
<ClCompile Include="..\md5.c" />
|
||||
<ClCompile Include="..\mserv.c" />
|
||||
<ClCompile Include="..\m_aatree.c" />
|
||||
<ClCompile Include="..\m_anigif.c" />
|
||||
<ClCompile Include="..\m_argv.c" />
|
||||
<ClCompile Include="..\m_bbox.c" />
|
||||
|
|
|
@ -294,6 +294,9 @@
|
|||
<ClInclude Include="..\md5.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\m_aatree.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\m_anigif.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
|
@ -666,6 +669,9 @@
|
|||
<ClCompile Include="..\md5.c">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\m_aatree.c">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\m_anigif.c">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -25,19 +25,38 @@
|
|||
#include "mac_alert.h"
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII)
|
||||
|
||||
int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3)
|
||||
{
|
||||
CFOptionFlags results;
|
||||
|
||||
CFUserNotificationDisplayAlert(0,
|
||||
kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag,
|
||||
NULL, NULL, NULL,
|
||||
CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII),
|
||||
CFStringCreateWithCString(NULL, message, kCFStringEncodingASCII),
|
||||
button1 != NULL ? CFStringCreateWithCString(NULL, button1, kCFStringEncodingASCII) : NULL,
|
||||
button2 != NULL ? CFStringCreateWithCString(NULL, button2, kCFStringEncodingASCII) : NULL,
|
||||
button3 != NULL ? CFStringCreateWithCString(NULL, button3, kCFStringEncodingASCII) : NULL,
|
||||
&results);
|
||||
CFStringRef cf_title = CFSTRINGIFY(title);
|
||||
CFStringRef cf_message = CFSTRINGIFY(message);
|
||||
CFStringRef cf_button1 = NULL;
|
||||
CFStringRef cf_button2 = NULL;
|
||||
CFStringRef cf_button3 = NULL;
|
||||
|
||||
if (button1 != NULL)
|
||||
cf_button1 = CFSTRINGIFY(button1);
|
||||
if (button2 != NULL)
|
||||
cf_button2 = CFSTRINGIFY(button2);
|
||||
if (button3 != NULL)
|
||||
cf_button3 = CFSTRINGIFY(button3);
|
||||
|
||||
CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag;
|
||||
|
||||
CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message,
|
||||
cf_button1, cf_button2, cf_button3, &results);
|
||||
|
||||
if (cf_button1 != NULL)
|
||||
CFRelease(cf_button1);
|
||||
if (cf_button2 != NULL)
|
||||
CFRelease(cf_button2);
|
||||
if (cf_button3 != NULL)
|
||||
CFRelease(cf_button3);
|
||||
CFRelease(cf_message);
|
||||
CFRelease(cf_title);
|
||||
|
||||
return (int)results;
|
||||
}
|
||||
|
|
|
@ -9,23 +9,29 @@ void OSX_GetResourcesPath(char * buffer)
|
|||
mainBundle = CFBundleGetMainBundle();
|
||||
if (mainBundle)
|
||||
{
|
||||
const int BUF_SIZE = 256; // because we somehow always know that
|
||||
|
||||
CFURLRef appUrlRef = CFBundleCopyBundleURL(mainBundle);
|
||||
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
|
||||
CFStringRef resources = CFStringCreateWithCString(kCFAllocatorMalloc, "/Contents/Resources", kCFStringEncodingASCII);
|
||||
const void* rawarray[2] = {macPath, resources};
|
||||
CFArrayRef array = CFArrayCreate(kCFAllocatorMalloc, rawarray, 2, NULL);
|
||||
CFStringRef separator = CFStringCreateWithCString(kCFAllocatorMalloc, "", kCFStringEncodingASCII);
|
||||
CFStringRef fullPath = CFStringCreateByCombiningStrings(kCFAllocatorMalloc, array, separator);
|
||||
const char * path = CFStringGetCStringPtr(fullPath, kCFStringEncodingASCII);
|
||||
strcpy(buffer, path);
|
||||
CFRelease(fullPath);
|
||||
path = NULL;
|
||||
CFRelease(array);
|
||||
CFRelease(resources);
|
||||
CFStringRef macPath;
|
||||
if (appUrlRef != NULL)
|
||||
macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
|
||||
else
|
||||
macPath = NULL;
|
||||
|
||||
const char* rawPath;
|
||||
|
||||
if (macPath != NULL)
|
||||
rawPath = CFStringGetCStringPtr(macPath, kCFStringEncodingASCII);
|
||||
else
|
||||
rawPath = NULL;
|
||||
|
||||
if (rawPath != NULL && (CFStringGetLength(macPath) + strlen("/Contents/Resources") < BUF_SIZE))
|
||||
{
|
||||
strcpy(buffer, rawPath);
|
||||
strcat(buffer, "/Contents/Resources");
|
||||
}
|
||||
|
||||
CFRelease(macPath);
|
||||
CFRelease(appUrlRef);
|
||||
//CFRelease(mainBundle);
|
||||
CFRelease(separator);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,10 +54,8 @@ typedef struct
|
|||
|
||||
#define lumpcache_t void *
|
||||
|
||||
// Annoying cyclic dependency workaround: this inlcusion must come after
|
||||
// the definition of MAX_WADPATH.
|
||||
#ifdef HWRENDER
|
||||
#include "m_misc.h"
|
||||
#include "m_aatree.h"
|
||||
#endif
|
||||
|
||||
typedef struct wadfile_s
|
||||
|
|
|
@ -145,6 +145,7 @@
|
|||
<ClCompile Include="..\lzf.c" />
|
||||
<ClCompile Include="..\md5.c" />
|
||||
<ClCompile Include="..\mserv.c" />
|
||||
<ClCompile Include="..\m_aatree.c" />
|
||||
<ClCompile Include="..\m_anigif.c" />
|
||||
<ClCompile Include="..\m_argv.c" />
|
||||
<ClCompile Include="..\m_bbox.c" />
|
||||
|
@ -300,6 +301,7 @@
|
|||
<ClInclude Include="..\lzf.h" />
|
||||
<ClInclude Include="..\md5.h" />
|
||||
<ClInclude Include="..\mserv.h" />
|
||||
<ClInclude Include="..\m_aatree.h" />
|
||||
<ClInclude Include="..\m_anigif.h" />
|
||||
<ClInclude Include="..\m_argv.h" />
|
||||
<ClInclude Include="..\m_bbox.h" />
|
||||
|
|
|
@ -255,6 +255,9 @@
|
|||
<ClCompile Include="..\lua_skinlib.c">
|
||||
<Filter>LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\m_aatree.c">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\m_anigif.c">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClCompile>
|
||||
|
@ -662,6 +665,9 @@
|
|||
<ClInclude Include="..\md5.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\m_aatree.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\m_anigif.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in a new issue