newline stomper and fixed warnings
This was SVN commit r473.
This commit is contained in:
parent
041e60f6ab
commit
15ca5cbf21
@ -45,4 +45,4 @@ private:
|
||||
float m_HeightScale;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -118,7 +118,7 @@ void CMapReader::UnpackTerrain(CFileUnpacker& unpacker)
|
||||
// unpack tile data
|
||||
u32 tilesPerSide=m_MapSize*PATCH_SIZE;
|
||||
m_Tiles.resize(SQR(tilesPerSide));
|
||||
unpacker.UnpackRaw(&m_Tiles[0],sizeof(STileDesc)*m_Tiles.size());
|
||||
unpacker.UnpackRaw(&m_Tiles[0],(u32)(sizeof(STileDesc)*m_Tiles.size()));
|
||||
}
|
||||
|
||||
// ApplyData: take all the input data, and rebuild the scene from it
|
||||
|
@ -36,7 +36,7 @@ void CMapWriter::SaveMap(const char* filename)
|
||||
// handle isn't in list
|
||||
static u16 GetHandleIndex(const Handle handle,const std::vector<Handle>& handles)
|
||||
{
|
||||
for (uint i=0;i<handles.size();i++) {
|
||||
for (uint i=0;i<(uint)handles.size();i++) {
|
||||
if (handles[i]==handle) {
|
||||
return i;
|
||||
}
|
||||
@ -50,7 +50,7 @@ static u16 GetHandleIndex(const Handle handle,const std::vector<Handle>& handles
|
||||
// object isn't in list
|
||||
static u16 GetObjectIndex(const CObjectEntry* object,const std::vector<CObjectEntry*>& objects)
|
||||
{
|
||||
for (uint i=0;i<objects.size();i++) {
|
||||
for (uint i=0;i<(uint)objects.size();i++) {
|
||||
if (objects[i]==object) {
|
||||
return i;
|
||||
}
|
||||
@ -81,7 +81,7 @@ void CMapWriter::EnumTerrainTextures(std::vector<CStr>& textures,
|
||||
CMiniPatch& mp=g_Terrain.GetPatch(i,j)->m_MiniPatches[m][k];
|
||||
u16 index=u16(GetHandleIndex(mp.Tex1,handles));
|
||||
if (index==0xffff) {
|
||||
index=handles.size();
|
||||
index=(u16)handles.size();
|
||||
handles.push_back(mp.Tex1);
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ void CMapWriter::EnumTerrainTextures(std::vector<CStr>& textures,
|
||||
}
|
||||
|
||||
// now find the texture names for each handle
|
||||
for (uint i=0;i<handles.size();i++) {
|
||||
for (uint i=0;i<(uint)handles.size();i++) {
|
||||
CStr texturename;
|
||||
CTextureEntry* texentry=g_TexMan.FindTexture(handles[i]);
|
||||
if (!texentry) {
|
||||
@ -122,12 +122,12 @@ void CMapWriter::EnumObjects(std::vector<CStr>& objectTypes,std::vector<SObjectD
|
||||
SObjectDesc* objptr=&objects[0];
|
||||
|
||||
// now iterate through all the units
|
||||
for (u32 j=0;j<units.size();j++) {
|
||||
for (u32 j=0;j<(u32)units.size();j++) {
|
||||
CUnit* unit=units[j];
|
||||
|
||||
u16 index=u16(GetObjectIndex(unit->GetObject(),objectsInUse));
|
||||
if (index==0xffff) {
|
||||
index=objectsInUse.size();
|
||||
index=(u16)objectsInUse.size();
|
||||
objectsInUse.push_back(unit->GetObject());
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ void CMapWriter::EnumObjects(std::vector<CStr>& objectTypes,std::vector<SObjectD
|
||||
}
|
||||
|
||||
// now build outgoing objectTypes array
|
||||
for (uint i=0;i<objectsInUse.size();i++) {
|
||||
for (uint i=0;i<(uint)objectsInUse.size();i++) {
|
||||
objectTypes.push_back(objectsInUse[i]->m_Name);
|
||||
}
|
||||
}
|
||||
@ -177,14 +177,14 @@ void CMapWriter::PackObjects(CFilePacker& packer)
|
||||
EnumObjects(objectTypes,objects);
|
||||
|
||||
// pack object types
|
||||
u32 numObjTypes=objectTypes.size();
|
||||
u32 numObjTypes=(u32)objectTypes.size();
|
||||
packer.PackRaw(&numObjTypes,sizeof(numObjTypes));
|
||||
for (uint i=0;i<numObjTypes;i++) {
|
||||
packer.PackString(objectTypes[i]);
|
||||
}
|
||||
|
||||
// pack object data
|
||||
u32 numObjects=objects.size();
|
||||
u32 numObjects=(u32)objects.size();
|
||||
packer.PackRaw(&numObjects,sizeof(numObjects));
|
||||
packer.PackRaw(&objects[0],sizeof(SObjectDesc)*numObjects);
|
||||
}
|
||||
@ -210,13 +210,13 @@ void CMapWriter::PackTerrain(CFilePacker& packer)
|
||||
EnumTerrainTextures(terrainTextures,tiles);
|
||||
|
||||
// pack texture names
|
||||
u32 numTextures=terrainTextures.size();
|
||||
u32 numTextures=(u32)terrainTextures.size();
|
||||
packer.PackRaw(&numTextures,sizeof(numTextures));
|
||||
for (uint i=0;i<numTextures;i++) {
|
||||
packer.PackString(terrainTextures[i]);
|
||||
}
|
||||
|
||||
// pack tile data
|
||||
packer.PackRaw(&tiles[0],sizeof(STileDesc)*tiles.size());
|
||||
packer.PackRaw(&tiles[0],(u32)(sizeof(STileDesc)*tiles.size()));
|
||||
}
|
||||
|
||||
|
@ -68,4 +68,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif // PARTICLE_H
|
||||
#endif // PARTICLE_H
|
||||
|
@ -83,4 +83,4 @@ private:
|
||||
float m_colour[4];
|
||||
};
|
||||
|
||||
#endif // SPRITE_H
|
||||
#endif // SPRITE_H
|
||||
|
@ -60,4 +60,4 @@ void CTextureEntry::BuildBaseColor()
|
||||
delete[] buf;
|
||||
|
||||
m_BaseColorValid=true;
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,8 @@ bool CGUI::HandleEvent(const SDL_Event& ev)
|
||||
// TODO Gee: Handle
|
||||
}
|
||||
// JW: what's the difference between mPress and mDown? what's the code below responsible for?
|
||||
/*/* // Generally if just mouse is clicked
|
||||
/*
|
||||
// Generally if just mouse is clicked
|
||||
if (m_pInput->mDown(NEMM_BUTTON1) && pNearest)
|
||||
{
|
||||
pNearest->HandleMessage(GUIM_MOUSE_DOWN_LEFT);
|
||||
@ -237,7 +238,7 @@ void CGUI::Initialize()
|
||||
|
||||
void CGUI::Process()
|
||||
{
|
||||
/*/*
|
||||
/*
|
||||
|
||||
// TODO Gee: check if m_pInput is valid, otherwise return
|
||||
/// assert(m_pInput);
|
||||
|
@ -12,4 +12,4 @@ using namespace std;
|
||||
void CGUISprite::Draw(const float &z, const CRect &rect, const CRect &clipping=CRect(0,0,0,0))
|
||||
{
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
@ -36,4 +36,4 @@ void CRadioButton::HandleMessage(const SGUIMessage &Message)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ gee@pyro.nu
|
||||
//--------------------------------------------------------
|
||||
// Error definitions
|
||||
//--------------------------------------------------------
|
||||
DEFINE_ERROR(PS_NAME_TAKEN, "Reference name is taken")
|
||||
DEFINE_ERROR(PS_OBJECT_FAIL, "Object provided is null")
|
||||
DEFINE_ERROR(PS_SETTING_FAIL, "Setting does not exist")
|
||||
DEFINE_ERROR(PS_VALUE_INVALID, "Value provided is syntactically incorrect")
|
||||
DEFINE_ERROR(PS_NEEDS_PGUI, "m_pGUI is NULL when needed for a requested operation")
|
||||
DEFINE_ERROR(PS_NAME_AMBIGUITY, "Two or more objects are sharing name")
|
||||
DEFINE_ERROR(PS_NEEDS_NAME, "An object are trying to fit into a GUI without a name")
|
||||
DEFINE_ERROR(PS_NAME_TAKEN, "Reference name is taken");
|
||||
DEFINE_ERROR(PS_OBJECT_FAIL, "Object provided is null");
|
||||
DEFINE_ERROR(PS_SETTING_FAIL, "Setting does not exist");
|
||||
DEFINE_ERROR(PS_VALUE_INVALID, "Value provided is syntactically incorrect");
|
||||
DEFINE_ERROR(PS_NEEDS_PGUI, "m_pGUI is NULL when needed for a requested operation");
|
||||
DEFINE_ERROR(PS_NAME_AMBIGUITY, "Two or more objects are sharing name");
|
||||
DEFINE_ERROR(PS_NEEDS_NAME, "An object are trying to fit into a GUI without a name");
|
||||
|
||||
DEFINE_ERROR(PS_LEXICAL_FAIL, "PS_LEXICAL_FAIL")
|
||||
DEFINE_ERROR(PS_SYNTACTICAL_FAIL, "PS_SYNTACTICAL_FAIL")
|
||||
DEFINE_ERROR(PS_LEXICAL_FAIL, "PS_LEXICAL_FAIL");
|
||||
DEFINE_ERROR(PS_SYNTACTICAL_FAIL, "PS_SYNTACTICAL_FAIL");
|
||||
|
@ -132,15 +132,15 @@ typedef std::vector<IGUIObject*> vector_pObjects;
|
||||
//--------------------------------------------------------
|
||||
// Error declarations
|
||||
//--------------------------------------------------------
|
||||
DECLARE_ERROR(PS_NAME_TAKEN)
|
||||
DECLARE_ERROR(PS_OBJECT_FAIL)
|
||||
DECLARE_ERROR(PS_SETTING_FAIL)
|
||||
DECLARE_ERROR(PS_VALUE_INVALID)
|
||||
DECLARE_ERROR(PS_NEEDS_PGUI)
|
||||
DECLARE_ERROR(PS_NAME_AMBIGUITY)
|
||||
DECLARE_ERROR(PS_NEEDS_NAME)
|
||||
DECLARE_ERROR(PS_NAME_TAKEN);
|
||||
DECLARE_ERROR(PS_OBJECT_FAIL);
|
||||
DECLARE_ERROR(PS_SETTING_FAIL);
|
||||
DECLARE_ERROR(PS_VALUE_INVALID);
|
||||
DECLARE_ERROR(PS_NEEDS_PGUI);
|
||||
DECLARE_ERROR(PS_NAME_AMBIGUITY);
|
||||
DECLARE_ERROR(PS_NEEDS_NAME);
|
||||
|
||||
DECLARE_ERROR(PS_LEXICAL_FAIL)
|
||||
DECLARE_ERROR(PS_SYNTACTICAL_FAIL)
|
||||
DECLARE_ERROR(PS_LEXICAL_FAIL);
|
||||
DECLARE_ERROR(PS_SYNTACTICAL_FAIL);
|
||||
|
||||
#endif
|
||||
|
@ -221,8 +221,8 @@ public:
|
||||
struct SFeedback
|
||||
{
|
||||
// Constants
|
||||
const static int Left=0;
|
||||
const static int Right=1;
|
||||
static const int Left=0;
|
||||
static const int Right=1;
|
||||
|
||||
/**
|
||||
* Reset all member data.
|
||||
|
@ -117,4 +117,4 @@ void IGUIButtonBehavior::DrawButton(const CRect &rect,
|
||||
}
|
||||
else GetGUI()->DrawSprite(sprite, z, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,4 +83,4 @@ void IGUIScrollBarOwner::Draw()
|
||||
{
|
||||
(*it)->Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <map>
|
||||
|
||||
|
||||
static struct BIT_BUF
|
||||
struct BIT_BUF
|
||||
{
|
||||
ulong buf;
|
||||
ulong cur; /* bit to be appended (toggled by add()) */
|
||||
@ -39,9 +39,7 @@ static struct BIT_BUF
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
bit_buf;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class T, int n> struct RingBuf
|
||||
|
@ -25,8 +25,10 @@
|
||||
#undef CONFIG_DISABLE_EXCEPTIONS
|
||||
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
# define HAVE_C99
|
||||
#ifdef __STDC_VERSION__ // nested #if to avoid ICC warning if not defined
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# define HAVE_C99
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -67,4 +67,4 @@ write_loop:
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #ifdef HAVE_ASM
|
||||
#endif // #ifdef HAVE_ASM
|
||||
|
@ -12,6 +12,8 @@
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
#pragma comment(lib, "glu32.lib")
|
||||
// cannot get rid of glu32 - seems to be loaded by opengl32,
|
||||
// even though dependency walker marks it as demand-loaded.
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -64,6 +64,16 @@ enum Conversion
|
||||
|
||||
static int convert_path(const char* src, char* dst, Conversion conv = TO_NATIVE)
|
||||
{
|
||||
/*
|
||||
// if there's a platform with multiple-character DIR_SEP,
|
||||
// scan through the path and add space for each separator found.
|
||||
const size_t len = strlen(p_path);
|
||||
|
||||
n_path = (const char*)malloc(len * sizeof(char));
|
||||
if(!n_path)
|
||||
return ERR_NO_MEM;
|
||||
*/
|
||||
|
||||
const char* s = src;
|
||||
char* d = dst;
|
||||
|
||||
@ -189,19 +199,6 @@ fail:
|
||||
// makes sure length < PATH_MAX.
|
||||
int file_make_native_path(const char* const path, char* const n_path)
|
||||
{
|
||||
/*
|
||||
// if there's a platform with multiple-character DIR_SEP,
|
||||
// scan through the path and add space for each separator found.
|
||||
const size_t len = strlen(p_path);
|
||||
|
||||
n_path = (const char*)malloc(len * sizeof(char));
|
||||
if(!n_path)
|
||||
return ERR_NO_MEM;
|
||||
*/
|
||||
|
||||
const char* portable = path;
|
||||
char* native = (char*)n_path;
|
||||
|
||||
strcpy(n_path, n_root_dir);
|
||||
return convert_path(path, n_path+n_root_dir_len, TO_NATIVE);
|
||||
}
|
||||
@ -509,7 +506,7 @@ struct ll_cb
|
||||
};
|
||||
|
||||
|
||||
int ll_start_io(File* const f, const off_t ofs, size_t size, void* const p, ll_cb* const lcb)
|
||||
static int ll_start_io(File* const f, const off_t ofs, size_t size, void* const p, ll_cb* const lcb)
|
||||
{
|
||||
CHECK_FILE(f);
|
||||
|
||||
@ -545,7 +542,7 @@ int ll_start_io(File* const f, const off_t ofs, size_t size, void* const p, ll_c
|
||||
|
||||
// as a convenience, return a pointer to the transfer buffer
|
||||
// (rather than expose the ll_cb internals)
|
||||
ssize_t ll_wait_io(ll_cb* const lcb, void*& p)
|
||||
static ssize_t ll_wait_io(ll_cb* const lcb, void*& p)
|
||||
{
|
||||
aiocb* cb = &lcb->cb;
|
||||
|
||||
@ -733,7 +730,7 @@ struct IO
|
||||
int pending : 1;
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(IO)
|
||||
H_TYPE_DEFINE(IO);
|
||||
|
||||
|
||||
// don't support forcibly closing files => don't need to keep track of
|
||||
@ -742,6 +739,8 @@ H_TYPE_DEFINE(IO)
|
||||
|
||||
static void IO_init(IO* io, va_list args)
|
||||
{
|
||||
UNUSED(args);
|
||||
|
||||
const size_t cb_size = round_up(sizeof(struct ll_cb), 16);
|
||||
io->cb = (ll_cb*)mem_alloc(cb_size, 16, MEM_ZERO);
|
||||
}
|
||||
@ -761,6 +760,8 @@ static void IO_dtor(IO* io)
|
||||
// aio_result, which would terminate the read.
|
||||
static int IO_reload(IO* io, const char* fn)
|
||||
{
|
||||
UNUSED(fn);
|
||||
|
||||
return io->cb? 0 : ERR_NO_MEM;
|
||||
}
|
||||
|
||||
@ -921,8 +922,6 @@ Handle file_start_io(File* const f, const off_t user_ofs, size_t user_size, void
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
const int op = (f->flags & FILE_WRITE)? LIO_WRITE : LIO_READ;
|
||||
|
||||
// cut off at EOF.
|
||||
// avoid min() due to type conversion warnings.
|
||||
const off_t bytes_left = f->size - user_ofs;
|
||||
|
@ -62,7 +62,7 @@ enum
|
||||
enum FILE_CB_FLAGS
|
||||
{
|
||||
// location
|
||||
LOC_DIR = BIT(0),
|
||||
LOC_DIR = BIT(0)
|
||||
};
|
||||
|
||||
|
||||
|
@ -110,11 +110,13 @@ struct Font
|
||||
uint list_base;
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(Font)
|
||||
H_TYPE_DEFINE(Font);
|
||||
|
||||
|
||||
static void Font_init(Font* f, va_list args)
|
||||
{
|
||||
UNUSED(f);
|
||||
UNUSED(args);
|
||||
}
|
||||
|
||||
static void Font_dtor(Font* f)
|
||||
|
@ -107,7 +107,7 @@ typedef H_VTbl* H_Type;
|
||||
sizeof(type), /* control block size */\
|
||||
#type /* name */\
|
||||
};\
|
||||
static H_Type H_##type = &V_##type;
|
||||
static H_Type H_##type = &V_##type
|
||||
|
||||
// note: we cast to void* pointers so the functions can be declared to
|
||||
// take the control block pointers, instead of requiring a cast in each.
|
||||
@ -256,7 +256,7 @@ guide to defining and using resources
|
||||
};
|
||||
|
||||
3) build its vtbl:
|
||||
H_TYPE_DEFINE(Res1)
|
||||
H_TYPE_DEFINE(Res1);
|
||||
|
||||
this defines the symbol H_Res1, which is used whenever the handle
|
||||
manager needs its type. it is only accessible to this module
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
static void heap_free(void* const p, const size_t size, const uintptr_t ctx)
|
||||
{
|
||||
UNUSED(p);
|
||||
UNUSED(size);
|
||||
|
||||
void* org_p = (void*)ctx;
|
||||
free(org_p);
|
||||
}
|
||||
@ -42,6 +45,8 @@ static const size_t POOL_CAP = 8*MB; // TODO: user editable
|
||||
|
||||
static void pool_free(void* const p, const size_t size, const uintptr_t ctx)
|
||||
{
|
||||
UNUSED(p);
|
||||
|
||||
size_t ofs = ctx;
|
||||
|
||||
// at end of pool? if so, 'free' it
|
||||
@ -159,11 +164,13 @@ struct Mem
|
||||
// alternative: switch(mem->type) in mem_dtor
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(Mem)
|
||||
H_TYPE_DEFINE(Mem);
|
||||
|
||||
|
||||
static void Mem_init(Mem* m, va_list args)
|
||||
{
|
||||
UNUSED(m);
|
||||
UNUSED(args);
|
||||
}
|
||||
|
||||
|
||||
@ -178,6 +185,9 @@ static void Mem_dtor(Mem* m)
|
||||
// (key == pointer we allocate)
|
||||
static int Mem_reload(Mem* m, const char* fn)
|
||||
{
|
||||
UNUSED(m);
|
||||
UNUSED(fn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "res.h"
|
||||
#include "file.h"
|
||||
#include "timer.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "sysdep/win/wfam.h"
|
||||
@ -66,16 +67,43 @@ int res_reload_changed_files()
|
||||
if(!initialized)
|
||||
return -1;
|
||||
|
||||
static double last_time;
|
||||
static char last_fn[VFS_MAX_PATH];
|
||||
|
||||
FAMEvent e;
|
||||
while(FAMPending(&fc) > 0)
|
||||
if(FAMNextEvent(&fc, &e) == 0)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char vfs_path[VFS_MAX_PATH];
|
||||
CHECK_ERR(file_make_portable_path(e.filename, path));
|
||||
CHECK_ERR(vfs_get_path(path, vfs_path));
|
||||
res_reload(vfs_path);
|
||||
}
|
||||
{
|
||||
if(FAMNextEvent(&fc, &e) < 0)
|
||||
continue;
|
||||
|
||||
char path[PATH_MAX];
|
||||
char vfs_path[VFS_MAX_PATH];
|
||||
CHECK_ERR(file_make_portable_path(e.filename, path));
|
||||
CHECK_ERR(vfs_get_path(path, vfs_path));
|
||||
|
||||
const char* fn = vfs_path;
|
||||
|
||||
// many apps save by creating a temp file, deleting the original,
|
||||
// and renaming the temp file. that leads to 2 reloads, which is slow.
|
||||
// so:
|
||||
// .. ignore temp files,
|
||||
char* ext = strrchr(fn, '.');
|
||||
if(ext && !strcmp(ext, ".tmp"))
|
||||
continue;
|
||||
// .. directory change (more info is upcoming anyway)
|
||||
if(!ext && e.code == FAMChanged) // dir changed
|
||||
continue;
|
||||
// .. and reloads for the same file within a small timeframe.
|
||||
double cur_time = get_time();
|
||||
if(cur_time - last_time < 50e-3 && !strcmp(last_fn, fn))
|
||||
continue;
|
||||
|
||||
res_reload(fn);
|
||||
debug_out("%s\n\n", fn);
|
||||
|
||||
last_time = get_time();
|
||||
strcpy(last_fn, fn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,4 +16,4 @@ extern int res_watch_dir(const char* const path, uint* const reqnum);
|
||||
|
||||
extern int res_cancel_watch(const uint reqnum);
|
||||
|
||||
extern int res_reload_changed_files();
|
||||
extern int res_reload_changed_files();
|
||||
|
@ -27,10 +27,12 @@ struct Sound
|
||||
int channel;
|
||||
};
|
||||
//build its vtbl
|
||||
H_TYPE_DEFINE(Sound)
|
||||
H_TYPE_DEFINE(Sound);
|
||||
|
||||
static void Sound_init(Sound* s, va_list args)
|
||||
{
|
||||
UNUSED(args);
|
||||
|
||||
s->channel = -1;
|
||||
}
|
||||
|
||||
@ -54,6 +56,8 @@ static void Sound_dtor(Sound* s)
|
||||
|
||||
Handle sound_load(const char* filename)
|
||||
{
|
||||
ONCE(FSOUND_Init(44100, 32, 0));
|
||||
|
||||
return h_alloc(H_Sound,filename,0,0);
|
||||
}
|
||||
|
||||
@ -77,4 +81,4 @@ int sound_stop(const Handle h)
|
||||
if(s->channel != -1)
|
||||
FSOUND_StopSound(s->channel);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,4 @@
|
||||
|
||||
extern Handle sound_load(const char* filename);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -53,6 +53,9 @@
|
||||
#endif // NO_PNG
|
||||
|
||||
|
||||
static const u32 INVALID_FORMAT = 0xffffffff;
|
||||
// used in local variables only; never written into Tex.
|
||||
|
||||
// filled by loader funcs => declare here
|
||||
struct Tex
|
||||
{
|
||||
@ -68,7 +71,7 @@ struct Tex
|
||||
int int_fmt;
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(Tex)
|
||||
H_TYPE_DEFINE(Tex);
|
||||
|
||||
|
||||
const u32 FMT_UNKNOWN = 0;
|
||||
@ -272,7 +275,7 @@ static int tga_load(const char* fn, const u8* ptr, size_t size, Tex* t)
|
||||
const u32 ofs = hdr_size;
|
||||
|
||||
// determine format
|
||||
u32 fmt = ~0;
|
||||
u32 fmt = INVALID_FORMAT;
|
||||
// .. grayscale
|
||||
if(type == 3)
|
||||
{
|
||||
@ -291,7 +294,7 @@ static int tga_load(const char* fn, const u8* ptr, size_t size, Tex* t)
|
||||
fmt = GL_BGRA;
|
||||
}
|
||||
|
||||
if(fmt == ~0)
|
||||
if(fmt == INVALID_FORMAT)
|
||||
err = "invalid format or bpp";
|
||||
if(desc & 0x30)
|
||||
err = "image is not bottom-up and left-to-right";
|
||||
@ -429,6 +432,8 @@ static inline bool raw_valid(const u8* p, size_t size)
|
||||
|
||||
static int raw_load(const char* fn, const u8* ptr, size_t size, Tex* t)
|
||||
{
|
||||
UNUSED(ptr);
|
||||
|
||||
static u32 fmts[5] = { 0, 0, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
|
||||
for(uint i = 1; i <= 4; i++)
|
||||
{
|
||||
@ -517,7 +522,7 @@ fail:
|
||||
goto ret;
|
||||
}
|
||||
|
||||
const u8** rows;
|
||||
const u8** rows = 0;
|
||||
// freed in cleanup code; need scoping on VC6 due to goto
|
||||
|
||||
{
|
||||
@ -532,14 +537,14 @@ fail:
|
||||
|
||||
const size_t pitch = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
const u32 fmts[8] = { 0, ~0, GL_RGB, ~0, GL_LUMINANCE_ALPHA, ~0, GL_RGBA, ~0 };
|
||||
const u32 fmt = color_type < 8? fmts[color_type] : ~0;
|
||||
const u32 fmts[8] = { 0, INVALID_FORMAT, GL_RGB, INVALID_FORMAT, GL_LUMINANCE_ALPHA, INVALID_FORMAT, GL_RGBA, INVALID_FORMAT };
|
||||
const u32 fmt = color_type < 8? fmts[color_type] : INVALID_FORMAT;
|
||||
const u32 bpp = (u32)(pitch / w * 8);
|
||||
const u32 ofs = 0; // libpng returns decoded image data; no header
|
||||
|
||||
if(prec != 8)
|
||||
msg = "channel precision != 8 bits";
|
||||
if(fmt == ~0)
|
||||
if(fmt == INVALID_FORMAT)
|
||||
msg = "color type is invalid (must be direct color)";
|
||||
if(msg)
|
||||
{
|
||||
@ -684,6 +689,8 @@ fail:
|
||||
|
||||
static void Tex_init(Tex* t, va_list args)
|
||||
{
|
||||
UNUSED(t);
|
||||
UNUSED(args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -278,7 +278,8 @@ int Dir::add_subdir(const char* const fn)
|
||||
return -1;
|
||||
}
|
||||
|
||||
subdirs[fn];
|
||||
const std::string fn_s(fn);
|
||||
subdirs[fn_s];
|
||||
// side effect: maps <fn> to a newly constructed Dir()
|
||||
// non-const => cannot be optimized away.
|
||||
return 0;
|
||||
@ -287,7 +288,8 @@ int Dir::add_subdir(const char* const fn)
|
||||
|
||||
Dir* Dir::find_subdir(const char* const fn)
|
||||
{
|
||||
SubDirIt it = subdirs.find(fn);
|
||||
const std::string fn_s(fn);
|
||||
SubDirIt it = subdirs.find(fn_s);
|
||||
if(it == subdirs.end())
|
||||
return 0;
|
||||
return &it->second;
|
||||
@ -308,7 +310,8 @@ int Dir::add_file(const char* const fn, const FileLoc* const loc)
|
||||
// for absolute clarity; the container holds const FileLoc* objects.
|
||||
// operator[] returns a reference to that.
|
||||
// need this typedef to work around a GCC bug?
|
||||
Data& old_loc = files[fn];
|
||||
const std::string fn_s(fn);
|
||||
Data& old_loc = files[fn_s];
|
||||
// old loc exists and is higher priority - keep it.
|
||||
if(old_loc && old_loc->pri > loc->pri)
|
||||
return 1;
|
||||
@ -320,7 +323,8 @@ int Dir::add_file(const char* const fn, const FileLoc* const loc)
|
||||
|
||||
const FileLoc* Dir::find_file(const char* const fn)
|
||||
{
|
||||
FileIt it = files.find(fn);
|
||||
const std::string fn_s(fn);
|
||||
FileIt it = files.find(fn_s);
|
||||
if(it == files.end())
|
||||
return 0;
|
||||
return it->second;
|
||||
@ -472,6 +476,8 @@ struct FileCBParams
|
||||
// just generate a list of archives here and mount them from the caller.
|
||||
static int add_dirent_cb(const char* const fn, const uint flags, const ssize_t size, const uintptr_t user)
|
||||
{
|
||||
UNUSED(size);
|
||||
|
||||
const FileCBParams* const params = (FileCBParams*)user;
|
||||
Dir* const cur_dir = params->dir;
|
||||
const FileLoc* const cur_loc = params->loc;
|
||||
@ -620,6 +626,8 @@ struct ArchiveCBParams
|
||||
// add each successfully opened archive to list.
|
||||
static int archive_cb(const char* const fn, const uint flags, const ssize_t size, const uintptr_t user)
|
||||
{
|
||||
UNUSED(size);
|
||||
|
||||
// not interested in subdirectories
|
||||
if(flags & LOC_DIR)
|
||||
return 0;
|
||||
@ -652,8 +660,6 @@ static int archive_cb(const char* const fn, const uint flags, const ssize_t size
|
||||
// mount list, when invalidating (reloading) the VFS.
|
||||
static int remount(Mount& m)
|
||||
{
|
||||
int err;
|
||||
|
||||
const char* const v_path = m.v_path.c_str();
|
||||
const char* const f_name = m.f_name.c_str();
|
||||
const uint pri = m.pri;
|
||||
@ -710,7 +716,7 @@ static inline void remount_all()
|
||||
{ std::for_each(mounts.begin(), mounts.end(), remount); }
|
||||
|
||||
|
||||
void vfs_shutdown(void)
|
||||
static void vfs_shutdown(void)
|
||||
{
|
||||
tree_clear();
|
||||
unmount_all();
|
||||
@ -833,6 +839,8 @@ H_TYPE_DEFINE(VDir);
|
||||
|
||||
static void VDir_init(VDir* vd, va_list args)
|
||||
{
|
||||
UNUSED(vd);
|
||||
UNUSED(args);
|
||||
}
|
||||
|
||||
static void VDir_dtor(VDir* vd)
|
||||
@ -1015,7 +1023,7 @@ enum
|
||||
// internal file state flags
|
||||
// make sure these don't conflict with vfs.h flags
|
||||
VF_OPEN = 0x100,
|
||||
VF_ZIP = 0x200,
|
||||
VF_ZIP = 0x200
|
||||
|
||||
};
|
||||
|
||||
@ -1035,7 +1043,7 @@ struct VFile
|
||||
// (especially in PARANOIA builds, which add a member!)
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(VFile)
|
||||
H_TYPE_DEFINE(VFile);
|
||||
|
||||
|
||||
// with #define PARANOIA, File and ZFile get an additional member,
|
||||
@ -1094,9 +1102,6 @@ static int VFile_reload(VFile* vf, const char* path)
|
||||
if(flags & VF_OPEN)
|
||||
return 0;
|
||||
|
||||
int err = -1;
|
||||
|
||||
|
||||
const FileLoc* loc;
|
||||
CHECK_ERR(tree_lookup(path, &loc));
|
||||
|
||||
@ -1202,7 +1207,7 @@ debug_out("vfs_load fn=%s\n", fn);
|
||||
p = mem_get_ptr(vf->hm, &size);
|
||||
if(p)
|
||||
{
|
||||
assert(vf_size(vf) == size && "vfs_load: mismatch between File and Mem size");
|
||||
assert(vf_size(vf) == (off_t)size && "vfs_load: mismatch between File and Mem size");
|
||||
hm = vf->hm;
|
||||
goto skip_read;
|
||||
}
|
||||
|
@ -128,6 +128,8 @@ found_ecdr:
|
||||
}
|
||||
|
||||
|
||||
#ifdef PARANOIA
|
||||
|
||||
// make sure the LFH fields match those passed (from the CDFH).
|
||||
// only used in PARANOIA builds - costs time when opening archives.
|
||||
static int zip_verify_lfh(const void* const file, const off_t lfh_ofs, const off_t file_ofs)
|
||||
@ -160,6 +162,8 @@ static int zip_verify_lfh(const void* const file, const off_t lfh_ofs, const off
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // #ifdef PARANOIA
|
||||
|
||||
|
||||
// extract information from the current Central Directory File Header;
|
||||
// advance cdfh to point to the next; return -1 on unrecoverable error,
|
||||
@ -527,11 +531,13 @@ struct ZArchive
|
||||
bool is_open;
|
||||
};
|
||||
|
||||
H_TYPE_DEFINE(ZArchive)
|
||||
H_TYPE_DEFINE(ZArchive);
|
||||
|
||||
|
||||
static void ZArchive_init(ZArchive* za, va_list args)
|
||||
{
|
||||
UNUSED(za);
|
||||
UNUSED(args);
|
||||
}
|
||||
|
||||
|
||||
@ -789,7 +795,7 @@ do\
|
||||
while(0);
|
||||
|
||||
|
||||
int zip_open_idx(const Handle ha, const i32 idx, ZFile* zf)
|
||||
static int zip_open_idx(const Handle ha, const i32 idx, ZFile* zf)
|
||||
{
|
||||
memset(zf, 0, sizeof(ZFile));
|
||||
|
||||
|
@ -359,4 +359,4 @@ again:
|
||||
pthread_setschedparam(pthread_self(), old_policy, &old_param);
|
||||
}
|
||||
|
||||
#endif // #ifndef _M_IX86
|
||||
#endif // #ifndef _M_IX86
|
||||
|
@ -78,12 +78,6 @@ struct Watch
|
||||
// user pointer from from FAMMonitorDirectory; passed to FAMEvent
|
||||
void* user_data;
|
||||
|
||||
// history to detect series of notifications, so we can skip
|
||||
// redundant reloads (slow)
|
||||
std::string last_path;
|
||||
DWORD last_action; // FILE_ACTION_* codes or 0
|
||||
DWORD last_ticks; // timestamp via GetTickCount
|
||||
|
||||
DWORD dummy_nbytes;
|
||||
// storage for RDC lpBytesReturned, to avoid BoundsChecker warning
|
||||
// (dox are unclear on whether the pointer must be valid).
|
||||
@ -99,13 +93,9 @@ struct Watch
|
||||
|
||||
|
||||
Watch()
|
||||
: last_path("")
|
||||
{
|
||||
hDir = INVALID_HANDLE_VALUE;
|
||||
|
||||
last_action = 0;
|
||||
last_ticks = 0;
|
||||
|
||||
// change_buf[] doesn't need init
|
||||
}
|
||||
|
||||
@ -376,22 +366,8 @@ static int extract_events(FAMConnection* fc, FAMRequest* fr, Watch* w)
|
||||
// fields are set below; we need to add the event here
|
||||
// so that we have a place to put the converted filename.
|
||||
|
||||
|
||||
//
|
||||
// interpret action
|
||||
//
|
||||
|
||||
const char* actions[] = { "", "FILE_ACTION_ADDED", "FILE_ACTION_REMOVED", "FILE_ACTION_MODIFIED", "FILE_ACTION_RENAMED_OLD_NAME", "FILE_ACTION_RENAMED_NEW_NAME" };
|
||||
const char* action = actions[fni->Action];
|
||||
|
||||
// many apps save by creating a temp file, deleting the original,
|
||||
// and renaming the temp file. that leads to 2 reloads, which is slow.
|
||||
// try to detect this case with a simple state machine - we assume
|
||||
// the notification order is always the same.
|
||||
|
||||
// TODO
|
||||
|
||||
FAMCodes code;
|
||||
FAMCodes code = FAMChanged;
|
||||
switch(fni->Action)
|
||||
{
|
||||
case FILE_ACTION_ADDED:
|
||||
@ -405,11 +381,12 @@ static int extract_events(FAMConnection* fc, FAMRequest* fr, Watch* w)
|
||||
case FILE_ACTION_MODIFIED:
|
||||
code = FAMChanged;
|
||||
break;
|
||||
default:
|
||||
debug_warn("unknown fni->Action");
|
||||
break;
|
||||
};
|
||||
|
||||
event.code = code;
|
||||
|
||||
|
||||
// build filename
|
||||
// (prepend directory and convert from Windows BSTR)
|
||||
strcpy(event.filename, w->dir_name.c_str());
|
||||
@ -419,14 +396,12 @@ static int extract_events(FAMConnection* fc, FAMRequest* fr, Watch* w)
|
||||
*fn++ = (char)fni->FileName[i];
|
||||
*fn = '\0';
|
||||
|
||||
|
||||
// advance to next entry in buffer (variable length)
|
||||
const DWORD ofs = fni->NextEntryOffset;
|
||||
// advance to next FILE_NOTIFY_INFORMATION (variable length)
|
||||
if(ofs)
|
||||
pos += ofs;
|
||||
// this was the last entry - no more elements left in buffer.
|
||||
else
|
||||
// .. this one was the last - done.
|
||||
if(!ofs)
|
||||
break;
|
||||
pos += ofs;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -70,4 +70,4 @@ extern int FAMNextEvent(FAMConnection*, FAMEvent* event);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // #ifndef WFAM_H__
|
||||
#endif // #ifndef WFAM_H__
|
||||
|
@ -49,4 +49,4 @@ WINGDIAPI PROC WINAPI wglGetProcAddress(LPCSTR);
|
||||
WINGDIAPI BOOL WINAPI wglMakeCurrent(HDC, HGLRC);
|
||||
WINGDIAPI BOOL WINAPI wglShareLists(HGLRC, HGLRC);
|
||||
WINGDIAPI BOOL WINAPI wglUseFontBitmapsA(HDC, DWORD, DWORD, DWORD);
|
||||
WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD);
|
||||
WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD);
|
||||
|
@ -337,7 +337,7 @@ struct RegisterModuleHelper
|
||||
#define WIN_REGISTER_MODULE(mod)\
|
||||
static int mod##_init();\
|
||||
static int mod##_shutdown();\
|
||||
static RegisterModuleHelper module__(mod##_init, mod##_shutdown);
|
||||
static RegisterModuleHelper module__(mod##_init, mod##_shutdown)
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ static bool fullscreen; /* in fullscreen mode?
|
||||
|
||||
static bool is_shutdown;
|
||||
|
||||
HWND hWnd = 0; /* available to the app for ShowWindow calls, etc. */
|
||||
static HWND hWnd = 0; /* make available to the app for ShowWindow calls, etc.? */
|
||||
|
||||
static DEVMODE dm; /* current video mode */
|
||||
static HDC hDC;
|
||||
@ -383,6 +383,8 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
||||
|
||||
WIN_REGISTER_MODULE(wsdl);
|
||||
|
||||
#include <io.h>
|
||||
|
||||
// SDL redirects stdout.txt in its WinMain hook. we need to do this
|
||||
// here (before main is called), instead of in SDL_Init,
|
||||
// to completely emulate SDL; bonus: we don't miss output before SDL_Init.
|
||||
@ -438,6 +440,7 @@ static int wsdl_shutdown()
|
||||
|
||||
int SDL_Init(Uint32 flags)
|
||||
{
|
||||
UNUSED(flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define Uint32 u32
|
||||
|
||||
/* SDL_Init flags */
|
||||
|
@ -27,6 +27,8 @@
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
#endif
|
||||
|
||||
static bool wsock_initialized;
|
||||
|
||||
|
||||
fp_getnameinfo_t getnameinfo;
|
||||
fp_getaddrinfo_t getaddrinfo;
|
||||
@ -64,7 +66,8 @@ static int wsock_init()
|
||||
|
||||
static int wsock_shutdown()
|
||||
{
|
||||
return WSACleanup();
|
||||
// only call WSACleanup if the library was loaded/used
|
||||
return wsock_initialized? WSACleanup() : 0;
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +88,8 @@ static FARPROC WINAPI delay_load_hook(unsigned dliNotify, PDelayLoadInfo pdli)
|
||||
if(dliNotify == dliNoteEndProcessing && !strncmp(pdli->szDll, "ws2_32", 6))
|
||||
{
|
||||
char d[1024];
|
||||
WSAStartup(0x0002, d); // want 2.0
|
||||
if(WSAStartup(0x0002, d) == 0) // want 2.0
|
||||
wsock_initialized = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -215,4 +215,4 @@ IMP(ssize_t, recvfrom, (int, void*, size_t, int, struct sockaddr*, socklen_t*))
|
||||
|
||||
#undef IMP
|
||||
|
||||
#endif // #ifndef WSOCK_H__
|
||||
#endif // #ifndef WSOCK_H__
|
||||
|
@ -466,6 +466,8 @@ static HANDLE hExitEvent;
|
||||
|
||||
static unsigned __stdcall calibration_thread(void* data)
|
||||
{
|
||||
UNUSED(data);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(WaitForSingleObject(hExitEvent, 1000) != WAIT_TIMEOUT)
|
||||
|
@ -78,4 +78,4 @@ extern int clock_getres(clockid_t clock, struct timespec* res);
|
||||
extern void wtime_reset_impl();
|
||||
|
||||
|
||||
#endif // #ifndef WTIME_H__
|
||||
#endif // #ifndef WTIME_H__
|
||||
|
@ -27,8 +27,10 @@ typedef unsigned int PS_uint;
|
||||
|
||||
// the standard only guarantees 16 bits.
|
||||
// we use this for memory offsets and ranges, so it better be big enough.
|
||||
#if defined(SIZE_MAX) && SIZE_MAX < 32
|
||||
#error "check size_t and SIZE_MAX - too small?"
|
||||
#ifdef SIZE_MAX // nested #if to avoid ICC warning if not defined
|
||||
# if SIZE_MAX < 32
|
||||
# error "check size_t and SIZE_MAX - too small?"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -540,12 +540,6 @@ PREVTSC=TSC;
|
||||
// (command line params may override these)
|
||||
get_cur_vmode(&g_xres, &g_yres, &g_bpp, &g_freq);
|
||||
|
||||
if(FSOUND_Init(44100, 32, 0) == 0)
|
||||
{
|
||||
swprintf(err_msg, ERR_MSG_SIZE, L"Failed to initialise FMOD");
|
||||
display_startup_error(err_msg);
|
||||
}
|
||||
|
||||
// set current directory to "$game_dir/data".
|
||||
// this is necessary because it is otherwise unknown,
|
||||
// especially if run from a shortcut / symlink.
|
||||
@ -626,7 +620,7 @@ PREVTSC=TSC;
|
||||
|
||||
font = font_load("fonts/verdana.fnt");
|
||||
|
||||
g_Console = new CConsole(0, g_yres-600.f, g_xres, 600.f);
|
||||
g_Console = new CConsole(0, g_yres-600.f, (float)g_xres, 600.f);
|
||||
|
||||
// create renderer
|
||||
new CRenderer;
|
||||
@ -685,7 +679,8 @@ if(!g_MapFile)
|
||||
|
||||
// Initialize entities
|
||||
|
||||
g_EntityManager.dispatchAll( &CMessage( CMessage::EMSG_INIT ) );
|
||||
CMessage init_msg (CMessage::EMSG_INIT);
|
||||
g_EntityManager.dispatchAll(&init_msg);
|
||||
|
||||
#ifndef NO_GUI
|
||||
in_add_handler(gui_handler);
|
||||
|
@ -247,4 +247,4 @@ double MathUtil::SignedModulus(const double &num, const double &n)
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -40,7 +40,7 @@ void CFilePacker::Write(const char* filename,u32 version,const char magicstr[4])
|
||||
}
|
||||
|
||||
// get size of data
|
||||
u32 datasize=m_Data.size();
|
||||
u32 datasize=(u32)m_Data.size();
|
||||
if (fwrite(&datasize,sizeof(datasize),1,fp)!=1) {
|
||||
fclose(fp);
|
||||
throw CFileWriteError();
|
||||
@ -61,7 +61,7 @@ void CFilePacker::Write(const char* filename,u32 version,const char magicstr[4])
|
||||
// PackRaw: pack given number of bytes onto the end of the data stream
|
||||
void CFilePacker::PackRaw(const void* rawdata,u32 rawdatalen)
|
||||
{
|
||||
u32 start=m_Data.size();
|
||||
u32 start=(u32)m_Data.size();
|
||||
m_Data.resize(m_Data.size()+rawdatalen);
|
||||
memcpy(&m_Data[start],rawdata,rawdatalen);
|
||||
|
||||
@ -71,7 +71,7 @@ void CFilePacker::PackRaw(const void* rawdata,u32 rawdatalen)
|
||||
// PackString: pack a string onto the end of the data stream
|
||||
void CFilePacker::PackString(const CStr& str)
|
||||
{
|
||||
u32 len=str.Length();
|
||||
u32 len=(u32)str.Length();
|
||||
PackRaw(&len,sizeof(len));
|
||||
PackRaw((const char*) str,len);
|
||||
}
|
||||
|
@ -301,4 +301,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -12,8 +12,8 @@ Standard declarations which are included in all projects.
|
||||
|
||||
typedef const char * PS_RESULT;
|
||||
|
||||
#define DEFINE_ERROR(x, y) PS_RESULT x=y;
|
||||
#define DECLARE_ERROR(x) extern PS_RESULT x;
|
||||
#define DEFINE_ERROR(x, y) PS_RESULT x=y
|
||||
#define DECLARE_ERROR(x) extern PS_RESULT x
|
||||
|
||||
DECLARE_ERROR(PS_OK);
|
||||
DECLARE_ERROR(PS_FAIL);
|
||||
|
@ -9,8 +9,20 @@
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "xerces-c_2.lib")
|
||||
#endif
|
||||
# ifdef XERCES_STATIC_LIB
|
||||
# ifndef NDEBUG
|
||||
# pragma comment(lib, "xerces-c_2-static.lib")
|
||||
# else
|
||||
# pragma comment(lib, "xerces-c_2-static.lib")
|
||||
# endif // NDEBUG
|
||||
# else
|
||||
# ifndef NDEBUG
|
||||
# pragma comment(lib, "xerces-c_2D.lib")
|
||||
# else
|
||||
# pragma comment(lib, "xerces-c_2.lib")
|
||||
# endif // NDEBUG
|
||||
# endif // XERCES_STATIC_LIB
|
||||
#endif // _MSC_VER
|
||||
|
||||
XERCES_CPP_NAMESPACE_USE
|
||||
|
||||
|
@ -63,7 +63,7 @@ void CModelRData::BuildIndices()
|
||||
}
|
||||
|
||||
// build indices
|
||||
u32 base=m_VB->m_Index;
|
||||
u32 base=(u32)m_VB->m_Index;
|
||||
u32 indices=0;
|
||||
SModelFace* faces=mdef->GetFaces();
|
||||
for (int j=0; j<mdef->GetNumFaces(); j++) {
|
||||
@ -265,9 +265,9 @@ float CModelRData::BackToFrontIndexSort(CMatrix3D& objToCam)
|
||||
u32 indices=0;
|
||||
for (i=0;i<numFaces;i++) {
|
||||
SModelFace& face=faces[IndexSorter[i].first];
|
||||
m_Indices[indices++]=face.m_Verts[0]+m_VB->m_Index;
|
||||
m_Indices[indices++]=face.m_Verts[1]+m_VB->m_Index;
|
||||
m_Indices[indices++]=face.m_Verts[2]+m_VB->m_Index;
|
||||
m_Indices[indices++]=(u16)(face.m_Verts[0]+m_VB->m_Index);
|
||||
m_Indices[indices++]=(u16)(face.m_Verts[1]+m_VB->m_Index);
|
||||
m_Indices[indices++]=(u16)(face.m_Verts[2]+m_VB->m_Index);
|
||||
}
|
||||
|
||||
// clear list for next call
|
||||
@ -320,9 +320,9 @@ void CModelRData::RenderModels(u32 streamflags)
|
||||
if (batch->m_IndexData.size()>0) {
|
||||
if (streamflags & STREAM_UV0) g_Renderer.BindTexture(0,tex_id(batch->m_Texture));
|
||||
for (uint j=0;j<batch->m_IndexData.size();j++) {
|
||||
glDrawElements(GL_TRIANGLES,batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
glDrawElements(GL_TRIANGLES,(GLsizei)batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
g_Renderer.m_Stats.m_DrawCalls++;
|
||||
g_Renderer.m_Stats.m_ModelTris+=batch->m_IndexData[j].first/2;
|
||||
g_Renderer.m_Stats.m_ModelTris+=(u32)batch->m_IndexData[j].first/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,12 +130,12 @@ void CPatchRData::BuildBlends()
|
||||
}
|
||||
}
|
||||
if (neighbourTextures.size()>0) {
|
||||
u32 count=neighbourTextures.size();
|
||||
u32 count=(u32)neighbourTextures.size();
|
||||
// sort textures from lowest to highest priority
|
||||
std::sort(neighbourTextures.begin(),neighbourTextures.end());
|
||||
|
||||
// for each of the neighbouring textures ..
|
||||
for (uint k=0;k<neighbourTextures.size();++k) {
|
||||
for (uint k=0;k<(uint)neighbourTextures.size();++k) {
|
||||
|
||||
// now build the grid of blends dependent on whether the tile adjacent to the current tile
|
||||
// uses the current neighbour texture
|
||||
@ -199,7 +199,7 @@ void CPatchRData::BuildBlends()
|
||||
int vsize=PATCH_SIZE+1;
|
||||
|
||||
SBlendVertex dst;
|
||||
int vindex=m_BlendVertices.size();
|
||||
int vindex=(int)m_BlendVertices.size();
|
||||
|
||||
const SBaseVertex& vtx0=m_Vertices[(j*vsize)+i];
|
||||
dst.m_UVs[0]=i*0.125f;
|
||||
@ -262,21 +262,20 @@ void CPatchRData::BuildBlends()
|
||||
m_VBBlends=g_VBMan.Allocate(sizeof(SBlendVertex),m_BlendVertices.size(),false);
|
||||
m_VBBlends->m_Owner->UpdateChunkVertices(m_VBBlends,&m_BlendVertices[0]);
|
||||
|
||||
|
||||
// now build outgoing splats
|
||||
m_BlendSplats.resize(splatTextures.size());
|
||||
int splatCount=0;
|
||||
|
||||
u32 base=m_VBBlends->m_Index;
|
||||
u32 base=(u32)m_VBBlends->m_Index;
|
||||
std::set<Handle>::iterator iter=splatTextures.begin();
|
||||
for (;iter!=splatTextures.end();++iter) {
|
||||
Handle tex=*iter;
|
||||
|
||||
SSplat& splat=m_BlendSplats[splatCount];
|
||||
splat.m_IndexStart=m_BlendIndices.size();
|
||||
splat.m_IndexStart=(u32)m_BlendIndices.size();
|
||||
splat.m_Texture=tex;
|
||||
|
||||
for (uint k=0;k<splats.size();k++) {
|
||||
for (uint k=0;k<(uint)splats.size();k++) {
|
||||
if (splats[k].m_Texture==tex) {
|
||||
m_BlendIndices.push_back(splats[k].m_Indices[0]+base);
|
||||
m_BlendIndices.push_back(splats[k].m_Indices[1]+base);
|
||||
@ -287,7 +286,6 @@ void CPatchRData::BuildBlends()
|
||||
}
|
||||
splatCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CPatchRData::BuildIndices()
|
||||
@ -318,13 +316,13 @@ void CPatchRData::BuildIndices()
|
||||
// now build base splats from interior textures
|
||||
m_Splats.resize(textures.size());
|
||||
// build indices for base splats
|
||||
u32 base=m_VBBase->m_Index;
|
||||
for (uint i=0;i<m_Splats.size();i++) {
|
||||
u32 base=(u32)m_VBBase->m_Index;
|
||||
for (uint i=0;i<(uint)m_Splats.size();i++) {
|
||||
Handle h=textures[i];
|
||||
|
||||
SSplat& splat=m_Splats[i];
|
||||
splat.m_Texture=h;
|
||||
splat.m_IndexStart=m_Indices.size();
|
||||
splat.m_IndexStart=(u32)m_Indices.size();
|
||||
|
||||
for (int j=0;j<PATCH_SIZE;j++) {
|
||||
for (int i=0;i<PATCH_SIZE;i++) {
|
||||
@ -336,7 +334,7 @@ void CPatchRData::BuildIndices()
|
||||
}
|
||||
}
|
||||
}
|
||||
splat.m_IndexCount=m_Indices.size()-splat.m_IndexStart;
|
||||
splat.m_IndexCount=(u32)m_Indices.size()-splat.m_IndexStart;
|
||||
}
|
||||
|
||||
// build indices for the shadow map pass
|
||||
@ -428,7 +426,7 @@ void CPatchRData::RenderBase()
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBaseVertex,m_UVs[0]));
|
||||
|
||||
// render each splat
|
||||
for (uint i=0;i<m_Splats.size();i++) {
|
||||
for (uint i=0;i<(uint)m_Splats.size();i++) {
|
||||
SSplat& splat=m_Splats[i];
|
||||
g_Renderer.BindTexture(0,tex_id(splat.m_Texture));
|
||||
glDrawElements(GL_QUADS,splat.m_IndexCount,GL_UNSIGNED_SHORT,&m_Indices[splat.m_IndexStart]);
|
||||
@ -450,11 +448,11 @@ void CPatchRData::RenderStreams(u32 streamflags)
|
||||
else if (streamflags & STREAM_POSTOUV0) glTexCoordPointer(3,GL_FLOAT,sizeof(SBaseVertex),base+offsetof(SBaseVertex,m_Position));
|
||||
|
||||
// render all base splats at once
|
||||
glDrawElements(GL_QUADS,m_Indices.size(),GL_UNSIGNED_SHORT,&m_Indices[0]);
|
||||
glDrawElements(GL_QUADS,(GLsizei)m_Indices.size(),GL_UNSIGNED_SHORT,&m_Indices[0]);
|
||||
|
||||
// bump stats
|
||||
g_Renderer.m_Stats.m_DrawCalls++;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=m_Indices.size()/2;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=(u32)m_Indices.size()/2;
|
||||
}
|
||||
|
||||
|
||||
@ -477,7 +475,7 @@ void CPatchRData::RenderBlends()
|
||||
glClientActiveTexture(GL_TEXTURE1_ARB);
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBlendVertex,m_AlphaUVs[0]));
|
||||
|
||||
for (uint i=0;i<m_BlendSplats.size();i++) {
|
||||
for (uint i=0;i<(uint)m_BlendSplats.size();i++) {
|
||||
SSplat& splat=m_BlendSplats[i];
|
||||
g_Renderer.BindTexture(0,tex_id(splat.m_Texture));
|
||||
glDrawElements(GL_QUADS,splat.m_IndexCount,GL_UNSIGNED_SHORT,&m_BlendIndices[splat.m_IndexStart]);
|
||||
@ -587,9 +585,9 @@ void CPatchRData::RenderBaseSplats()
|
||||
if (batch->m_IndexData.size()>0) {
|
||||
g_Renderer.BindTexture(0,tex_id(batch->m_Texture));
|
||||
for (uint j=0;j<batch->m_IndexData.size();j++) {
|
||||
glDrawElements(GL_QUADS,batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
glDrawElements(GL_QUADS,(GLsizei)batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
g_Renderer.m_Stats.m_DrawCalls++;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=batch->m_IndexData[j].first/2;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=(u32)batch->m_IndexData[j].first/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -680,9 +678,9 @@ void CPatchRData::RenderBlendSplats()
|
||||
if (batch->m_IndexData.size()>0) {
|
||||
g_Renderer.BindTexture(0,tex_id(batch->m_Texture));
|
||||
for (uint j=0;j<batch->m_IndexData.size();j++) {
|
||||
glDrawElements(GL_QUADS,batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
glDrawElements(GL_QUADS,(GLsizei)batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
g_Renderer.m_Stats.m_DrawCalls++;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=batch->m_IndexData[j].first/2;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=(u32)batch->m_IndexData[j].first/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -784,9 +782,9 @@ void CPatchRData::ApplyShadowMap(GLuint shadowmaphandle)
|
||||
// render batch (can only be one per buffer, since all batches are flagged as using a null texture)
|
||||
const CVertexBuffer::Batch* batch=batches[0];
|
||||
for (uint j=0;j<batch->m_IndexData.size();j++) {
|
||||
glDrawElements(GL_QUADS,batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
glDrawElements(GL_QUADS,(GLsizei)batch->m_IndexData[j].first,GL_UNSIGNED_SHORT,batch->m_IndexData[j].second);
|
||||
g_Renderer.m_Stats.m_DrawCalls++;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=batch->m_IndexData[j].first/2;
|
||||
g_Renderer.m_Stats.m_TerrainTris+=(u32)batch->m_IndexData[j].first/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -804,4 +802,4 @@ void CPatchRData::ApplyShadowMap(GLuint shadowmaphandle)
|
||||
glDisable(GL_BLEND);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
|
@ -190,4 +190,4 @@ void CTransparencyRenderer::RenderObjectsStreams(u32 streamflags)
|
||||
CModelRData* modeldata=(CModelRData*) m_Objects[i].m_Model->GetRenderData();
|
||||
modeldata->RenderStreams(streamflags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,4 +182,4 @@ u8* CVertexBuffer::Bind()
|
||||
base=(u8*) m_SysMem;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
@ -97,4 +97,4 @@ private:
|
||||
static std::vector<Batch*> m_FreeBatches;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -5,7 +5,6 @@
|
||||
// Contact: rich@wildfiregames.com
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "precompiled.h"
|
||||
#include <assert.h>
|
||||
#include "ogl.h"
|
||||
@ -62,4 +61,4 @@ void CVertexBufferManager::ClearBatchIndices()
|
||||
CVertexBuffer* buffer=*iter;
|
||||
buffer->ClearBatchIndices();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,4 +38,4 @@ private:
|
||||
extern CVertexBufferManager g_VBMan;
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -43,7 +43,7 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation )
|
||||
|
||||
CEntity::~CEntity()
|
||||
{
|
||||
for( i32 i = 0; i < m_base->m_inheritors.size(); i++ )
|
||||
for( size_t i = 0; i < m_base->m_inheritors.size(); i++ )
|
||||
if( m_base->m_inheritors[i] == this )
|
||||
m_base->m_inheritors.erase( m_base->m_inheritors.begin() + i );
|
||||
|
||||
@ -126,7 +126,7 @@ float CEntity::getExactGroundLevel( float x, float y )
|
||||
u16* heightmap = g_Terrain.GetHeightMap();
|
||||
unsigned long mapsize = g_Terrain.GetVerticesPerSide();
|
||||
|
||||
assert( ( xi >= 0 ) && ( xi < mapsize ) && ( yi >= 0 ) && ( yi < mapsize ) );
|
||||
assert( ( xi >= 0 ) && ( xi < (int)mapsize ) && ( yi >= 0 ) && ( yi < (int)mapsize ) );
|
||||
|
||||
float h00 = heightmap[yi*mapsize + xi];
|
||||
float h01 = heightmap[yi*mapsize + xi + mapsize];
|
||||
|
@ -66,8 +66,8 @@ bool CProperty_i32::rebuild( CProperty* parent, bool triggerFn )
|
||||
newvalue = *_parent;
|
||||
if( modifier )
|
||||
{
|
||||
newvalue *= modifier->multiplicative;
|
||||
newvalue += modifier->additive;
|
||||
newvalue = (i32)(newvalue * modifier->multiplicative);
|
||||
newvalue += (i32)modifier->additive;
|
||||
}
|
||||
if( data == newvalue )
|
||||
return( false ); // No change.
|
||||
@ -150,7 +150,7 @@ CProperty_float::operator jsval()
|
||||
|
||||
CProperty_float::operator bool()
|
||||
{
|
||||
return( data );
|
||||
return( data != 0.0f);
|
||||
}
|
||||
|
||||
float CProperty_float::operator+( float value )
|
||||
|
Loading…
Reference in New Issue
Block a user