diff --git a/CMakeLists.txt b/CMakeLists.txt index c02bc8c9..d1d31396 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,19 +47,22 @@ IF (APPLE) ENDIF() IF (WIN32) + SET(CMAKE_FIND_LIBRARY_PREFIXES "") + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") + + FIND_PACKAGE( SDL REQUIRED ) + FIND_PACKAGE( SDL_image REQUIRED ) + MESSAGE( "SDL Include Dir is " ${SDL_INCLUDE_DIR} ) + SET(D3_GAMEDIR "c:/games/Descent3/") set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "lib/win" "lib/win/directx") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Gm /EHsc /RTC1 /W3 /nologo /c /ZI /TP /errorReport:prompt") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL /FD /EHsc /W3 /nologo /c /Zi /TP /errorReport:prompt") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC") - SET(CMAKE_MODULE_LINKER_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC") - ADD_DEFINITIONS (-DIS_WINDOWS -D_CRT_SECURE_NO_WARNINGS -DMONO -DWIN32 -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + SET(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC") + ADD_DEFINITIONS (-DIS_WINDOWS -D_CRT_SECURE_NO_WARNINGS -DMONO -DWIN32 -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DDO_SDL) - SET(PLATFORM_INCLUDES "lib/win/directx" "lib/win") - - SET(CMAKE_FIND_LIBRARY_PREFIXES "") - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") + SET(PLATFORM_INCLUDES "lib/win/directx" ${SDL_INCLUDE_DIR} "lib/win") FIND_LIBRARY(DSOUND_LIBRARY NAMES dsound "${CMAKE_SOURCE_DIR}/lib/win" "${CMAKE_SOURCE_DIR}/lib/win/directx") FIND_LIBRARY(DINPUT_LIBRARY NAMES dinput "${CMAKE_SOURCE_DIR}/lib/win" "${CMAKE_SOURCE_DIR}/lib/win/directx") diff --git a/Descent3/AImain.cpp b/Descent3/AImain.cpp index 3be7e398..de56f053 100644 --- a/Descent3/AImain.cpp +++ b/Descent3/AImain.cpp @@ -3429,17 +3429,16 @@ start_loop: obj->rtype.pobj_info.anim_frame = from; } -#ifdef MACINTOSH // DAJ - if (obj->rtype.pobj_info.anim_frame + 0.001 < from || obj->rtype.pobj_info.anim_frame > to) + if (obj->rtype.pobj_info.anim_frame + 0.001 < from || obj->rtype.pobj_info.anim_frame > to) { mprintf((2, "AI ANIM from %0.6f (%0.6f) to %0.6f\n", from, obj->rtype.pobj_info.anim_frame, to)); - if (obj->rtype.pobj_info.anim_frame < from) + } + if (obj->rtype.pobj_info.anim_frame < from) { obj->rtype.pobj_info.anim_frame = from; - if (obj->rtype.pobj_info.anim_frame > to) + } + if (obj->rtype.pobj_info.anim_frame > to) { obj->rtype.pobj_info.anim_frame = to; -#else + } - ASSERT(obj->rtype.pobj_info.anim_frame >= from && obj->rtype.pobj_info.anim_frame <= to); -#endif return; done: diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index 71e3723b..e079003b 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -1197,17 +1197,11 @@ int BOAGetMineChecksum() { face *fp = &rp->faces[t]; for (k = 0; k < fp->num_verts; k++) { -#ifdef MACINTOSH int x, y, z; x = floor(rp->verts[fp->face_verts[k]].x); y = floor(rp->verts[fp->face_verts[k]].y); z = floor(rp->verts[fp->face_verts[k]].z); total += x + y + z; -#else - total += rp->verts[fp->face_verts[k]].x; - total += rp->verts[fp->face_verts[k]].y; - total += rp->verts[fp->face_verts[k]].z; -#endif } total += fp->num_verts << 4; diff --git a/Descent3/CMakeLists.txt b/Descent3/CMakeLists.txt index d38e6549..285caf82 100644 --- a/Descent3/CMakeLists.txt +++ b/Descent3/CMakeLists.txt @@ -277,10 +277,10 @@ SET (CPPS IF (WIN32) -SET (PLATFORM_LIBS dd_sndlib dd_grwin32 dd_vidwin32 ddio_win win32 wsock32.lib winmm.lib Glu32.lib +SET (PLATFORM_LIBS dd_sndlib dd_grwin32 dd_vidwin32 ddio_win win32 ${SDL_LIBRARY} wsock32.lib winmm.lib Glu32.lib ${DSOUND_LIBRARY} ${DINPUT_LIBRARY} ${DXGUID_LIBRARY} ${DDRAW_LIBRARY}) SET (PLATFORM_CPPS winmain.cpp ) -SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC") +SET(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC /SAFESEH:NO") ENDIF() diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index ef857456..0bed0d6b 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -682,14 +682,14 @@ bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn); void mn3_Close(); inline bool IS_MN3_FILE(const char *fname) { - char name[PSFILENAME_LEN]; - char ext[PSFILENAME_LEN]; + char name[PSFILENAME_LEN + 1]; + char ext[PSFILENAME_LEN + 1]; ddio_SplitPath(fname, NULL, name, ext); return (strcmpi(ext, ".mn3") == 0) ? true : false; } inline char *MN3_TO_MSN_NAME(const char *mn3name, char *msnname) { - char fname[PSFILENAME_LEN]; + char fname[PSFILENAME_LEN + 1]; ddio_SplitPath(mn3name, NULL, fname, NULL); if (stricmp(fname, "d3_2") == 0) { @@ -888,15 +888,15 @@ bool LoadMission(const char *mssn) { tMission *msn; CFILE *fp = NULL; // Mission file char errtext[80]; // Stores error if unable to read mission - char msnfname[PSFILENAME_LEN]; - char mission[_MAX_PATH * 2]; + char msnfname[PSPATHNAME_LEN]; + char mission[PSPATHNAME_LEN]; int srclinenum = 0; // Current line of source. int curlvlnum; // Current level number int numlevels; // Number of levels required to read in. int cur_objective; // current objective reading. bool indesc; // are we in a multi-line block bool res = false; // used to specify if no error has occurred. - char pathname[_MAX_PATH * 2]; + char pathname[PSPATHNAME_LEN]; ResetMission(); // Reset everything. // open MN3 if filename passed was an mn3 file. @@ -1639,7 +1639,7 @@ bool Skip_next_movie = false; // --------------------------------------------------------------------------- // play movie void DoMissionMovie(char *movie) { - char temppath[PSPATHNAME_LEN + PSFILENAME_LEN]; + char temppath[PSPATHNAME_LEN]; if (PROGRAM(windowed)) { mprintf((0, "Skipping movie...can't do in windowed mode!\n")); return; @@ -1829,13 +1829,17 @@ int Mission_voice_hog_handle = 0; // MN3 based mission functions. // loads the msn file from the mn3 file specified, specifies the hog and table file. bool mn3_Open(const char *mn3file) { - char pathname[PSPATHNAME_LEN + PSFILENAME_LEN]; - char filename[PSFILENAME_LEN]; + char pathname[PSPATHNAME_LEN]; + char filename[PSFILENAME_LEN + 1]; char ext[PSFILENAME_LEN]; int mn3_handle; // concatanate the mn3 extension if it isn't there. + char tempMn3File[PSPATHNAME_LEN]; if (!IS_MN3_FILE(mn3file)) { - strcat(filename, ".mn3"); + strncpy(tempMn3File, mn3file, sizeof(tempMn3File) - 1); + tempMn3File[sizeof(tempMn3File) - 1] = 0; + strcat(tempMn3File, ".mn3"); + mn3file = tempMn3File; } char *p = GetMultiCDPath((char *)mn3file); @@ -1874,8 +1878,8 @@ bool mn3_Open(const char *mn3file) { bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn) { int handle; bool retval; - char pathname[PSPATHNAME_LEN + PSFILENAME_LEN]; - char filename[PSFILENAME_LEN]; + char pathname[PSPATHNAME_LEN]; + char filename[PSFILENAME_LEN + 1]; if (strcmpi(mn3file, "d3.mn3") == 0) { char *p = GetMultiCDPath((char *)mn3file); diff --git a/Descent3/args.cpp b/Descent3/args.cpp index e36e8aa7..584b3a18 100644 --- a/Descent3/args.cpp +++ b/Descent3/args.cpp @@ -96,7 +96,7 @@ int FindArg(char *which) { } // if } // for - mprintf((0, "FindArg: Did not find [%s] on command line.\n", argBuf)); + mprintf((0, "FindArg: Did not find [%s] on command line.", argBuf)); delete[] argBuf; return (0); } // FindArg diff --git a/Descent3/cinematics.cpp b/Descent3/cinematics.cpp index 0c8dc462..45d8c8f0 100644 --- a/Descent3/cinematics.cpp +++ b/Descent3/cinematics.cpp @@ -62,7 +62,7 @@ bool PlayMovie(const char *moviename) { return false; // get in the right directory - char filename[PSPATHNAME_LEN]; + char filename[_MAX_PATH]; strncpy(filename, moviename, sizeof(filename) - 1); filename[sizeof(filename) - 1] = 0; diff --git a/Descent3/cockpit.cpp b/Descent3/cockpit.cpp index 2bed457e..12ec67de 100644 --- a/Descent3/cockpit.cpp +++ b/Descent3/cockpit.cpp @@ -197,12 +197,12 @@ #define BUFFET_PERIOD 0.25f #define COCKPIT_SHIFT_DELTA 0.02f typedef struct tCockpitCfgInfo { - char modelname[PSFILENAME_LEN]; - char shieldrings[NUM_SHIELD_GAUGE_FRAMES][PSFILENAME_LEN]; - char shipimg[PSFILENAME_LEN]; - char burnimg[PSFILENAME_LEN]; - char energyimg[PSFILENAME_LEN]; - char invpulseimg[PSFILENAME_LEN]; + char modelname[PSFILENAME_LEN+1]; + char shieldrings[NUM_SHIELD_GAUGE_FRAMES][PSFILENAME_LEN+1]; + char shipimg[PSFILENAME_LEN+1]; + char burnimg[PSFILENAME_LEN+1]; + char energyimg[PSFILENAME_LEN+1]; + char invpulseimg[PSFILENAME_LEN+1]; } tCockpitCfgInfo; typedef struct tCockpitInfo { int state; // current state of cockpit on screen. diff --git a/Descent3/gamesave.cpp b/Descent3/gamesave.cpp index 5b19618d..60b4e996 100644 --- a/Descent3/gamesave.cpp +++ b/Descent3/gamesave.cpp @@ -321,7 +321,7 @@ void QuickSaveGame() { SaveGameDialog(); } else { // verify savegame still exists in the appropriate slot, if not just run dialog, if so then save - char filename[PSFILENAME_LEN]; + char filename[PSFILENAME_LEN+1]; char pathname[PSPATHNAME_LEN]; char desc[GAMESAVE_DESCLEN + 1]; FILE *fp; @@ -358,8 +358,8 @@ void SaveGameDialog() { newuiSheet *sheet; int i, res; - char savegame_dir[PSPATHNAME_LEN + 1]; - char pathname[PSPATHNAME_LEN + 1]; + char savegame_dir[PSPATHNAME_LEN]; + char pathname[PSPATHNAME_LEN]; char filename[PSFILENAME_LEN + 1]; char desc[GAMESAVE_DESCLEN + 1]; bool occupied_slot[N_SAVE_SLOTS]; @@ -563,8 +563,8 @@ bool LoadGameDialog() { int i, res; bool retval = true; - char savegame_dir[PSPATHNAME_LEN + 1]; - char pathname[PSPATHNAME_LEN + 1]; + char savegame_dir[PSPATHNAME_LEN]; + char pathname[PSPATHNAME_LEN]; char filename[PSFILENAME_LEN + 1]; char desc[GAMESAVE_DESCLEN + 1]; bool occupied_slot[N_SAVE_SLOTS], loadgames_avail = false; diff --git a/Descent3/menu.cpp b/Descent3/menu.cpp index d1573f98..715321be 100644 --- a/Descent3/menu.cpp +++ b/Descent3/menu.cpp @@ -1145,7 +1145,7 @@ bool MenuNewGame() { FirstGame = true; - char temppath[PSFILENAME_LEN * 2]; + char temppath[PSPATHNAME_LEN]; char *moviepath; moviepath = GetMultiCDPath("level1.mve"); if (moviepath) { diff --git a/Descent3/mission_download.cpp b/Descent3/mission_download.cpp index 429f3a83..cc0796af 100644 --- a/Descent3/mission_download.cpp +++ b/Descent3/mission_download.cpp @@ -590,7 +590,7 @@ int msn_CheckGetMission(network_address *net_addr, char *filename) { return p ? 1 : 0; } - char pathname[PSFILENAME_LEN * 2]; + char pathname[PSPATHNAME_LEN]; ddio_MakePath(pathname, D3MissionsDir, filename, NULL); if (cfexist(filename) || cfexist(pathname)) { return 1; @@ -840,7 +840,7 @@ int CheckGetD3M(char *d3m) { char modurl[MAX_MISSION_URL_LEN + 1]; char *lowurl; - char pathname[PSFILENAME_LEN * 2]; + char pathname[PSPATHNAME_LEN]; char *fixedd3m = NULL; ddio_MakePath(pathname, LocalD3Dir, "Netgames", d3m, NULL); diff --git a/Descent3/newui.cpp b/Descent3/newui.cpp index 388ad10d..18cba807 100644 --- a/Descent3/newui.cpp +++ b/Descent3/newui.cpp @@ -1252,7 +1252,7 @@ const char *NewUIFileDialog::GetFilename() { return m_NewPath; } void NewUIFileDialog::UpdateList() { char search_str[PSPATHNAME_LEN]; - char filename[PSFILENAME_LEN + 1]; + char filename[PSPATHNAME_LEN]; // remove items from listbox, free them. while (m_ListBox.GetNumItems()) { @@ -1303,7 +1303,7 @@ bool NewUIFileDialog::DoModal() { case UID_FILELIST: index = m_ListBox.GetSelectedIndex(); filename = ((UITextItem *)m_ListBox.GetItem(index))->GetBuffer(); - ASSERT(strlen(filename) < (PSPATHNAME_LEN - 1)); + ASSERT(strlen(filename) < (PSPATHNAME_LEN)); strcpy(m_NewPath, filename); return_value = true; exit_menu = true; diff --git a/cfile/hog.cpp b/cfile/hog.cpp index 829f738b..d4b6f983 100644 --- a/cfile/hog.cpp +++ b/cfile/hog.cpp @@ -144,7 +144,7 @@ bool ReadHogHeader(FILE *fp, tHogHeader *header) { } bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) { int res = 0; - res = fread(entry->name, sizeof(char), PSFILENAME_LEN + 1, fp); + res = fread(entry->name, sizeof(char), HOG_FILENAME_LEN, fp); res = fread(&entry->flags, sizeof(entry->flags), 1, fp); entry->flags = INTEL_INT(entry->flags); res = fread(&entry->len, sizeof(entry->len), 1, fp); @@ -160,7 +160,7 @@ bool ReadHogEntry(FILE *fp, tHogFileEntry *entry) { bool WRITE_FILE_ENTRY(FILE *fp, tHogFileEntry *entry) { int res = 0; - res = fwrite(entry->name, sizeof(char), PSFILENAME_LEN + 1, fp); + res = fwrite(entry->name, sizeof(char), HOG_FILENAME_LEN, fp); res = fwrite(&entry->flags, sizeof(entry->flags), 1, fp); res = fwrite(&entry->len, sizeof(entry->len), 1, fp); res = fwrite(&entry->timestamp, sizeof(entry->timestamp), 1, fp); diff --git a/grtext/grfont.cpp b/grtext/grfont.cpp index 5a9222b1..93d70048 100644 --- a/grtext/grfont.cpp +++ b/grtext/grfont.cpp @@ -486,7 +486,7 @@ bool grfont_LoadTemplate(char *fname, tFontTemplate *ft) { ft->newstyle = (ft_flags & FT_FMT4444) ? true : false; ft->ffi2 = (ft_flags & FT_FFI2) ? true : false; - ft->ch_tracking = (sbyte)ffi2.tracking; + ft->ch_tracking = (sbyte)((ft_flags & FT_FFI2) ? ffi2.tracking : 0); CLOSE_FONT(ff); diff --git a/lib/InfFile.h b/lib/InfFile.h index c94e92ee..08caec7c 100644 --- a/lib/InfFile.h +++ b/lib/InfFile.h @@ -51,7 +51,7 @@ private: struct sym_info // full runtime symbol { - char name[PSFILENAME_LEN + 1]; + char name[PSPATHNAME_LEN]; char *text; }; diff --git a/lib/hogfile.h b/lib/hogfile.h index 89d8496b..bfc662e8 100644 --- a/lib/hogfile.h +++ b/lib/hogfile.h @@ -44,8 +44,9 @@ #include "pstypes.h" -#define HOG_HDR_SIZE 64 +#define HOG_HDR_SIZE (64) #define HOG_TAG_STR "HOG2" +#define HOG_FILENAME_LEN (36) typedef struct tHogHeader { unsigned nfiles; // number of files in header @@ -53,7 +54,7 @@ typedef struct tHogHeader { } tHogHeader; typedef struct tHogFileEntry { - char name[PSFILENAME_LEN + 1]; // file name + char name[HOG_FILENAME_LEN]; // file name unsigned flags; // extra info unsigned len; // length of file unsigned long timestamp; // time of file. diff --git a/lib/pstypes.h b/lib/pstypes.h index 86720551..a634019a 100644 --- a/lib/pstypes.h +++ b/lib/pstypes.h @@ -1,6 +1,8 @@ #ifndef _TYPES_H #define _TYPES_H +#include + // define unsigned types; typedef unsigned char ubyte; typedef signed char sbyte; @@ -24,7 +26,7 @@ typedef long long longlong; // The maximum length of a path (or path+filename). The seems (from looking at the code) to // include the terminating NULL. lengthened to 512 to prevent problems with some long pathnames. -#define PSPATHNAME_LEN 512 +#define PSPATHNAME_LEN _MAX_PATH #if !defined(__APPLE__) #define HOST_BIGENDIAN @HOST_BIGENDIAN @ diff --git a/libmve/mveasm.cpp b/libmve/mveasm.cpp index c1acf2e1..1fee1a3a 100644 --- a/libmve/mveasm.cpp +++ b/libmve/mveasm.cpp @@ -584,9 +584,9 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned ///////////////////////////////////////////////////////////////////////////// // Note: this is all you should have to tweak bool opcodesToProcess[16] = {true, true, true, true, // 0 - 3 - true, true, true, true, // 4 - 7 - true, true, false, true, // 8 - 11 - true, true, true, true}; // 12 - 15 + false, false, false, false, // 4 - 7 + false, false, false, true, // 8 - 11 + true, true, true, true}; // 12 - 15 if (!opcodesToProcess[opcode_to_use]) { opcode_to_use = SkipOpcode(opcode_to_use, hiColor, esi, bcomp, edi); } @@ -756,17 +756,11 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned const int max_repcount = 8; for (int rep_count = 0; rep_count < max_repcount; ++rep_count) { const unsigned char *color_idx = lookupTable + (esi[rep_count + kOffset] * 4); -#ifdef OUTRAGE_BIG_ENDIAN - unsigned int w1 = colors[color_idx[3]]; - unsigned int w2 = colors[color_idx[2]]; - unsigned int w3 = colors[color_idx[1]]; - unsigned int w4 = colors[color_idx[0]]; -#else unsigned int w1 = colors[color_idx[0]]; unsigned int w2 = colors[color_idx[1]]; unsigned int w3 = colors[color_idx[2]]; unsigned int w4 = colors[color_idx[3]]; -#endif + if (hiColor) { *(unsigned int *)(edi + 0) = w1; *(unsigned int *)(edi + 4) = w2; @@ -820,17 +814,10 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned } const unsigned char *color_idx = lookupTable + (idx * 4); -#ifdef OUTRAGE_BIG_ENDIAN - unsigned int w1 = colors[color_idx[3]]; - unsigned int w2 = colors[color_idx[2]]; - unsigned int w3 = colors[color_idx[1]]; - unsigned int w4 = colors[color_idx[0]]; -#else unsigned int w1 = colors[color_idx[0]]; unsigned int w2 = colors[color_idx[1]]; unsigned int w3 = colors[color_idx[2]]; unsigned int w4 = colors[color_idx[3]]; -#endif if (hiColor) { *(unsigned int *)(edi + 0) = w1; @@ -922,17 +909,10 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned for (int rep_count = 0; rep_count < max_repcount; ++rep_count) { int idx = repLookup[rep_count]; const unsigned char *color_idx = lookupTable + (esi[idx] * 4); -#ifdef OUTRAGE_BIG_ENDIAN - unsigned int w1 = colors[color_idx[3]]; - unsigned int w2 = colors[color_idx[2]]; - unsigned int w3 = colors[color_idx[1]]; - unsigned int w4 = colors[color_idx[0]]; -#else unsigned int w1 = colors[color_idx[0]]; unsigned int w2 = colors[color_idx[1]]; unsigned int w3 = colors[color_idx[2]]; unsigned int w4 = colors[color_idx[3]]; -#endif if (hiColor) { *(unsigned int *)(edi + 0) = w1; @@ -1135,17 +1115,11 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned for (int rep_count = 0; rep_count < max_repcount; ++rep_count) { int idx = repLookupTable[rep_count]; const unsigned char *color_idx = lookupTable + (esi[idx] * 4); -#ifdef OUTRAGE_BIG_ENDIAN - unsigned int w1 = colors[color_idx[3]]; - unsigned int w2 = colors[color_idx[2]]; - unsigned int w3 = colors[color_idx[1]]; - unsigned int w4 = colors[color_idx[0]]; -#else unsigned int w1 = colors[color_idx[0]]; unsigned int w2 = colors[color_idx[1]]; unsigned int w3 = colors[color_idx[2]]; unsigned int w4 = colors[color_idx[3]]; -#endif + if (hiColor) { *(unsigned int *)(edi + 0) = w1; *(unsigned int *)(edi + 4) = w2; @@ -1242,25 +1216,6 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned unsigned int w4 = colors[color_idx[3]]; if (rep_count & 1) { -#ifdef OUTRAGE_BIG_ENDIAN - if (hiColor) { - *(unsigned int *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); - *(unsigned int *)(edi + nf_width + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); - - *(unsigned int *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16); - *(unsigned int *)(edi + nf_width + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16); - } else { - *(unsigned char *)(edi + 4) = w4; - *(unsigned char *)(edi + 5) = w3; - *(unsigned char *)(edi + 6) = w2; - *(unsigned char *)(edi + 7) = w1; - - *(unsigned char *)(edi + nf_width + 4) = w4; - *(unsigned char *)(edi + nf_width + 5) = w3; - *(unsigned char *)(edi + nf_width + 6) = w2; - *(unsigned char *)(edi + nf_width + 7) = w1; - } -#else if (hiColor) { *(unsigned int *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); *(unsigned int *)(edi + nf_width + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); @@ -1278,25 +1233,17 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned *(unsigned char *)(edi + nf_width + 6) = w3; *(unsigned char *)(edi + nf_width + 7) = w4; } -#endif + edi += nf_width * 2; } else { if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 0) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16); - *(unsigned int *)(edi + nf_width) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16); - - *(unsigned int *)(edi + 4) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16); - *(unsigned int *)(edi + nf_width + 4) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16); -#else *(unsigned int *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); *(unsigned int *)(edi + nf_width) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); *(unsigned int *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16); *(unsigned int *)(edi + nf_width + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16); -#endif } else { - const unsigned int value = IntelSwapper((unsigned int)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1); + const unsigned int value = ( w4 << 24 ) | ( w3 << 16 ) | ( w2 << 8 ) | w1; *(unsigned int *)(edi) = value; *(unsigned int *)(edi + nf_width) = value; } @@ -1334,23 +1281,6 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned unsigned int w2 = colors[color_idx[1]]; unsigned int w3 = colors[color_idx[2]]; unsigned int w4 = colors[color_idx[3]]; -#ifdef OUTRAGE_BIG_ENDIAN - if (hiColor) { - *(unsigned int *)(edi + 0) = w4; - *(unsigned int *)(edi + 4) = w3; - *(unsigned int *)(edi + 8) = w2; - *(unsigned int *)(edi + 12) = w1; - } else { - *(unsigned char *)(edi + 0) = w4; - *(unsigned char *)(edi + 1) = w4; - *(unsigned char *)(edi + 2) = w3; - *(unsigned char *)(edi + 3) = w3; - *(unsigned char *)(edi + 4) = w2; - *(unsigned char *)(edi + 5) = w2; - *(unsigned char *)(edi + 6) = w1; - *(unsigned char *)(edi + 7) = w1; - } -#else if (hiColor) { *(unsigned int *)(edi + 0) = w1; *(unsigned int *)(edi + 4) = w2; @@ -1367,7 +1297,6 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned *(unsigned char *)(edi + 7) = w4; } -#endif edi += nf_width; } @@ -1403,16 +1332,6 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned unsigned int w4 = colors[color_idx[3]]; if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 0) = w4; - *(unsigned int *)(edi + nf_width) = w4; - *(unsigned int *)(edi + 4) = w3; - *(unsigned int *)(edi + nf_width + 4) = w3; - *(unsigned int *)(edi + 8) = w2; - *(unsigned int *)(edi + nf_width + 8) = w2; - *(unsigned int *)(edi + 12) = w1; - *(unsigned int *)(edi + nf_width + 12) = w1; -#else *(unsigned int *)(edi + 0) = w1; *(unsigned int *)(edi + nf_width) = w1; *(unsigned int *)(edi + 4) = w2; @@ -1421,10 +1340,9 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned *(unsigned int *)(edi + nf_width + 8) = w3; *(unsigned int *)(edi + 12) = w4; *(unsigned int *)(edi + nf_width + 12) = w4; -#endif } else { - unsigned int c0 = IntelSwapper((unsigned int)(w2 << 24) | (w2 << 16) | (w1 << 8) | w1); - unsigned int c1 = IntelSwapper((unsigned int)(w4 << 24) | (w4 << 16) | (w3 << 8) | w3); + unsigned int c0 = ( w2 << 24 ) | ( w2 << 16 ) | ( w1 << 8 ) | w1; + unsigned int c1 = ( w4 << 24 ) | ( w4 << 16 ) | ( w3 << 8 ) | w3; *(unsigned int *)(edi + 0) = c0; *(unsigned int *)(edi + nf_width) = c0; *(unsigned int *)(edi + 4) = c1; @@ -1465,29 +1383,19 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned if (rep_count & 1) { if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 8) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16); - *(unsigned int *)(edi + 12) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16); -#else *(unsigned int *)(edi + 8) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); *(unsigned int *)(edi + 12) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16); -#endif } else { - *(unsigned int *)(edi + 4) = IntelSwapper((unsigned int)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1); + *(unsigned int*)(edi + 4) = ( w4 << 24 ) | ( w3 << 16 ) | ( w2 << 8 ) | w1; } edi += nf_width; } else { if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 0) = (w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16); - *(unsigned int *)(edi + 4) = (w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16); -#else *(unsigned int *)(edi + 0) = (w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16); *(unsigned int *)(edi + 4) = (w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16); -#endif } else { - *(unsigned int *)(edi + 0) = IntelSwapper((unsigned int)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1); + *(unsigned int*)(edi + 0) = ( w4 << 24 ) | ( w3 << 16 ) | ( w2 << 8 ) | w1; } } } @@ -1569,44 +1477,28 @@ void PkDecompWorker(const bool hiColor, const unsigned char *ops, const unsigned if (!do42) { if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 0) = ((unsigned int)(w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16)); - *(unsigned int *)(edi + 4) = ((unsigned int)(w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16)); -#else - *(unsigned int *)(edi + 0) = ((unsigned int)(w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16)); - *(unsigned int *)(edi + 4) = ((unsigned int)(w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16)); -#endif + *(unsigned int *)(edi+0) = (w1&0xFFFF)|((w2&0xFFFF)<<16); + *(unsigned int *)(edi+4) = (w3&0xFFFF)|((w4&0xFFFF)<<16); } else { - *(unsigned int *)(edi + 0) = IntelSwapper((unsigned int)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1); + *(unsigned int *)(edi+0) = (w4 << 24) | (w3 << 16) | (w2 << 8) | w1; } edi += nf_width; } else { // 42 if (rep_count & 1) { if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 8) = ((unsigned int)(w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16)); - *(unsigned int *)(edi + 12) = ((unsigned int)(w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16)); -#else - - *(unsigned int *)(edi + 8) = ((unsigned int)(w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16)); - *(unsigned int *)(edi + 12) = ((unsigned int)(w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16)); -#endif + *(unsigned int *)(edi+8) = (w1&0xFFFF)|((w2&0xFFFF)<<16); + *(unsigned int *)(edi+12) = (w3&0xFFFF)|((w4&0xFFFF)<<16); } else { - *(unsigned int *)(edi + 4) = IntelSwapper((unsigned int)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1); + *(unsigned int *)(edi+4) = (w4 << 24) | (w3 << 16) | (w2 << 8) | w1; } edi += nf_width; } else { if (hiColor) { -#ifdef OUTRAGE_BIG_ENDIAN - *(unsigned int *)(edi + 0) = ((unsigned int)(w4 & 0xFFFF) | ((w3 & 0xFFFF) << 16)); - *(unsigned int *)(edi + 4) = ((unsigned int)(w2 & 0xFFFF) | ((w1 & 0xFFFF) << 16)); -#else - *(unsigned int *)(edi + 0) = ((unsigned int)(w1 & 0xFFFF) | ((w2 & 0xFFFF) << 16)); - *(unsigned int *)(edi + 4) = ((unsigned int)(w3 & 0xFFFF) | ((w4 & 0xFFFF) << 16)); -#endif + *(unsigned int *)(edi+0) = (w1&0xFFFF)|((w2&0xFFFF)<<16); + *(unsigned int *)(edi+4) = (w3&0xFFFF)|((w4&0xFFFF)<<16); } else { - *(unsigned int *)(edi + 0) = IntelSwapper((unsigned int)(w4 << 24) | (w3 << 16) | (w2 << 8) | w1); + *(unsigned int *)(edi+0) = (w4 << 24) | (w3 << 16) | (w2 << 8) | w1; } } } diff --git a/libmve/mvelibl.cpp b/libmve/mvelibl.cpp index 21e0a08e..966b4208 100644 --- a/libmve/mvelibl.cpp +++ b/libmve/mvelibl.cpp @@ -231,10 +231,8 @@ static bool ioReset(int h) { io_handle = h; hdr = (mve_hdr *)ioRead(sizeof(mve_hdr) + sizeof(ioHdrRec)); - if (!hdr) - return false; hdr->SwapBytes(); - if (strcmp(hdr->FileType, MVE_FILE_TYPE) != 0 || hdr->id != ~hdr->version + 0x1234 || + if (!hdr || strcmp(hdr->FileType, MVE_FILE_TYPE) != 0 || hdr->id != ~hdr->version + 0x1234 || // The following two checks may eventually be weakened. hdr->version != MVE_FILE_VERSION || hdr->HdrSize != sizeof(mve_hdr)) return false; diff --git a/model/newstyle.cpp b/model/newstyle.cpp index 76f4d6db..aeec337c 100644 --- a/model/newstyle.cpp +++ b/model/newstyle.cpp @@ -1135,7 +1135,7 @@ float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bo poly_model *pm; matrix m; float normalized_time[MAX_SUBOBJECTS]; - int i, j, n; + int model_index, sm_vert_index, frame_index; float cur_dist; float size = 0.0; int start_frame = 0; @@ -1156,26 +1156,27 @@ float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bo if (offset_ptr) { vector min_xyz; vector max_xyz; + bool first_pnt = true; - for (n = start_frame; n <= end_frame; n++) { + for(frame_index = start_frame; frame_index <= end_frame; frame_index++) { // Because size changes with animation, we need the worst case point -- so, check every keyframe // NOTE: This code does not currently account for all $turret and $rotate positions - SetNormalizedTimeAnim(n, normalized_time, pm); + SetNormalizedTimeAnim(frame_index, normalized_time, pm); SetModelAnglesAndPos(pm, normalized_time); - for (i = 0; i < pm->n_models; i++) { - bsp_info *sm = &pm->submodel[i]; + for (model_index = 0;model_index < pm->n_models; model_index++) { + bsp_info *sm = &pm->submodel[model_index]; // For every vertex - for (j = 0; j < sm->nverts; j++) { + for(sm_vert_index = 0; sm_vert_index < sm->nverts; sm_vert_index++) { vector pnt; int mn; // Get the point and its current sub-object - pnt = sm->verts[j]; - mn = i; + pnt = sm->verts[sm_vert_index]; + mn = model_index; // Instance up the tree while (mn != -1) { @@ -1200,7 +1201,8 @@ float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bo // *gun_point += obj->pos; // Find the min_xyz and max_xyz - if (n == start_frame && i == 0 && j == 0) { + if (first_pnt) { + first_pnt = false; min_xyz = max_xyz = pnt; } else { if (pnt.x < min_xyz.x) @@ -1226,25 +1228,25 @@ float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bo *offset_ptr = geometric_center; } - for (n = start_frame; n <= end_frame; n++) { + for(frame_index = start_frame; frame_index <= end_frame; frame_index++) { // Because size changes with animation, we need the worst case point -- so, check every keyframe // NOTE: This code does not currently account for all $turret and $rotate positions - SetNormalizedTimeAnim(n, normalized_time, pm); + SetNormalizedTimeAnim(frame_index, normalized_time, pm); SetModelAnglesAndPos(pm, normalized_time); - for (i = 0; i < pm->n_models; i++) { - bsp_info *sm = &pm->submodel[i]; + for(model_index = 0; model_index < pm->n_models; model_index++) { + bsp_info *sm = &pm->submodel[model_index]; // For every vertex - for (j = 0; j < sm->nverts; j++) { + for(sm_vert_index = 0; sm_vert_index < sm->nverts; sm_vert_index++) { vector pnt; int mn; // Get the point and its current sub-object - pnt = sm->verts[j]; - mn = i; + pnt = sm->verts[sm_vert_index]; + mn = model_index; // Instance up the tree while (mn != -1) { diff --git a/physics/Collide.cpp b/physics/Collide.cpp index ad1600e2..cbd1badb 100644 --- a/physics/Collide.cpp +++ b/physics/Collide.cpp @@ -985,7 +985,7 @@ void FindHitpointUV(float *u, float *v, vector *point, room *rp, int facenum) { vec1.j = pnt[2].j - pnt[1].j; k1 = -((cross(&checkp, &vec0) + cross(&vec0, &pnt[1])) / cross(&vec0, &vec1)); - if (abs((int)vec0.i) > abs((int)vec0.j)) + if (fabsf(vec0.i) > fabsf(vec0.j)) k0 = ((-k1 * vec1.i) + checkp.i - pnt[1].i) / vec0.i; else k0 = ((-k1 * vec1.j) + checkp.j - pnt[1].j) / vec0.j; diff --git a/renderer/SoftwareOpenGL.cpp b/renderer/SoftwareOpenGL.cpp index 93df88e8..82303b67 100644 --- a/renderer/SoftwareOpenGL.cpp +++ b/renderer/SoftwareOpenGL.cpp @@ -820,7 +820,7 @@ int opengl_Init(oeApplication *app, renderer_preferred_state *pref_state) { OpenGL_multitexture = false; if (OpenGL_packed_pixels) { - opengl_packed_Upload_data = (ushort *)mem_malloc(256 * 256 * 2); + opengl_packed_Upload_data = (ushort *)mem_malloc(2048 * 2048 * 2); opengl_packed_Translate_table = (ushort *)mem_malloc(65536 * 2); opengl_packed_4444_translate_table = (ushort *)mem_malloc(65536 * 2);