summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorerorcun <erayorcunus@gmail.com>2020-07-24 19:36:26 +0200
committerGitHub <noreply@github.com>2020-07-24 19:36:26 +0200
commit53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5 (patch)
treeee2e85916ffadc40bc0564348ac5041196cbf28a /src
parentupdate librw (diff)
parent64-bit on Windows (diff)
downloadre3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.tar
re3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.tar.gz
re3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.tar.bz2
re3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.tar.lz
re3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.tar.xz
re3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.tar.zst
re3-53e7cbbd5acf94efe8d123db4b0f5d8d0aa6b2e5.zip
Diffstat (limited to 'src')
-rw-r--r--src/audio/oal/aldlist.cpp3
-rw-r--r--src/audio/oal/stream.cpp9
-rw-r--r--src/control/Replay.cpp4
-rw-r--r--src/core/Camera.cpp6
-rw-r--r--src/core/Directory.cpp3
-rw-r--r--src/core/EventList.cpp6
-rw-r--r--src/core/EventList.h2
-rw-r--r--src/core/FileMgr.cpp16
-rw-r--r--src/core/FileMgr.h6
-rw-r--r--src/core/Frontend.cpp2
-rw-r--r--src/core/Game.cpp2
-rw-r--r--src/core/Pad.cpp2
-rw-r--r--src/core/Streaming.cpp19
-rw-r--r--src/core/Streaming.h10
-rw-r--r--src/core/common.h4
-rw-r--r--src/peds/Ped.cpp2
-rw-r--r--src/peds/PedAttractor.cpp10
-rw-r--r--src/peds/PedAttractor.h4
-rw-r--r--src/peds/PedStats.cpp2
-rw-r--r--src/peds/PedType.cpp2
-rw-r--r--src/render/Fluff.cpp2
-rw-r--r--src/rw/NodeName.cpp2
-rw-r--r--src/rw/VisibilityPlugins.cpp4
-rw-r--r--src/rw/VisibilityPlugins.h6
-rw-r--r--src/skel/crossplatform.h2
-rw-r--r--src/skel/glfw/glfw.cpp2
-rw-r--r--src/skel/win/win.cpp47
-rw-r--r--src/skel/win/win.h8
-rw-r--r--src/text/Text.cpp26
-rw-r--r--src/text/Text.h14
-rw-r--r--src/weapons/WeaponInfo.cpp2
31 files changed, 140 insertions, 89 deletions
diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp
index 3e86b1d7..881418c1 100644
--- a/src/audio/oal/aldlist.cpp
+++ b/src/audio/oal/aldlist.cpp
@@ -27,6 +27,7 @@
#ifndef _WIN32
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
+#define _strdup strdup
#endif
#ifdef AUDIO_OAL
@@ -71,7 +72,7 @@ ALDeviceList::ALDeviceList()
if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) {
ALDEVICEINFO ALDeviceInfo;
ALDeviceInfo.bSelected = true;
- ALDeviceInfo.strDeviceName = actualDeviceName;
+ ALDeviceInfo.strDeviceName = _strdup(actualDeviceName);
alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion);
alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion);
diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp
index 0378c07c..40ec57fa 100644
--- a/src/audio/oal/stream.cpp
+++ b/src/audio/oal/stream.cpp
@@ -5,7 +5,11 @@
#include "sampman.h"
#ifdef _WIN32
+
+// TODO: This is due to version difference of 32-bit libmpg123 and 64-bit libmpg123, fix it
+#ifndef _WIN64
typedef long ssize_t;
+#endif
#pragma comment( lib, "libsndfile-1.lib" )
#pragma comment( lib, "libmpg123.lib" )
#else
@@ -173,8 +177,11 @@ public:
size_t size;
int err = mpg123_read(m_pMH, (unsigned char *)buffer, GetBufferSize(), &size);
+#if defined(__LP64__) || defined(_WIN64)
+ assert("We can't handle audio files more then 2 GB yet :shrug:" && (size < UINT32_MAX));
+#endif
if (err != MPG123_OK && err != MPG123_DONE) return 0;
- return size;
+ return (uint32)size;
}
};
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 8b34cc3b..1a050bee 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1483,7 +1483,7 @@ void CReplay::StreamAllNecessaryCarsAndPeds(void)
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
continue;
- for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
+ for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
switch (Buffers[slot][offset]) {
case REPLAYPACKET_VEHICLE:
CStreaming::RequestModel(((tVehicleUpdatePacket*)&Buffers[slot][offset])->mi, 0);
@@ -1505,7 +1505,7 @@ void CReplay::FindFirstFocusCoordinate(CVector *coord)
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
continue;
- for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
+ for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
if (Buffers[slot][offset] == REPLAYPACKET_GENERAL) {
*coord = ((tGeneralPacket*)&Buffers[slot][offset])->player_pos;
return;
diff --git a/src/core/Camera.cpp b/src/core/Camera.cpp
index eeb8630a..9f3646e2 100644
--- a/src/core/Camera.cpp
+++ b/src/core/Camera.cpp
@@ -3376,15 +3376,15 @@ CCamera::LoadTrainCamNodes(char const *name)
char token[16] = { 0 };
char filename[16] = { 0 };
uint8 *buf;
- int bufpos = 0;
+ size_t bufpos = 0;
int field = 0;
int tokpos = 0;
char c;
int i;
- int len;
+ size_t len;
strcpy(filename, name);
- len = strlen(filename);
+ len = (int)strlen(filename);
filename[len] = '.';
filename[len+1] = 'd';
filename[len+2] = 'a';
diff --git a/src/core/Directory.cpp b/src/core/Directory.cpp
index cc4d65d8..05344065 100644
--- a/src/core/Directory.cpp
+++ b/src/core/Directory.cpp
@@ -30,7 +30,8 @@ CDirectory::ReadDirFile(const char *filename)
bool
CDirectory::WriteDirFile(const char *filename)
{
- int fd, n;
+ int fd;
+ size_t n;
fd = CFileMgr::OpenFileForWriting(filename);
n = CFileMgr::Write(fd, (char*)entries, numEntries*sizeof(DirectoryInfo));
CFileMgr::CloseFile(fd);
diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp
index 4fab29bc..e5f264c7 100644
--- a/src/core/EventList.cpp
+++ b/src/core/EventList.cpp
@@ -189,7 +189,7 @@ CEventList::FindClosestEvent(eEventType type, CVector posn, int32 *event)
// --MIAMI: Done
void
-CEventList::ReportCrimeForEvent(eEventType type, int32 crimeId, bool copsDontCare)
+CEventList::ReportCrimeForEvent(eEventType type, size_t crimeId, bool copsDontCare)
{
eCrimeType crime;
switch(type){
@@ -227,10 +227,10 @@ CEventList::ReportCrimeForEvent(eEventType type, int32 crimeId, bool copsDontCar
if(CWanted::WorkOutPolicePresence(playerCoors, 14.0f) != 0 ||
CGame::germanGame && (crime == CRIME_SHOOT_PED || crime == CRIME_SHOOT_COP || crime == CRIME_COP_BURNED || crime == CRIME_VEHICLE_BURNED)){
- FindPlayerPed()->m_pWanted->RegisterCrime_Immediately(crime, playerPedCoors, crimeId, copsDontCare);
+ FindPlayerPed()->m_pWanted->RegisterCrime_Immediately(crime, playerPedCoors, (uint32)crimeId, copsDontCare);
FindPlayerPed()->m_pWanted->SetWantedLevelNoDrop(1);
}else
- FindPlayerPed()->m_pWanted->RegisterCrime(crime, playerPedCoors, crimeId, copsDontCare);
+ FindPlayerPed()->m_pWanted->RegisterCrime(crime, playerPedCoors, (uint32)crimeId, copsDontCare);
if(type == EVENT_ASSAULT_POLICE)
FindPlayerPed()->SetWantedLevelNoDrop(1);
diff --git a/src/core/EventList.h b/src/core/EventList.h
index f2c3d7a8..0531aed7 100644
--- a/src/core/EventList.h
+++ b/src/core/EventList.h
@@ -61,7 +61,7 @@ public:
static bool GetEvent(eEventType type, int32 *event);
static void ClearEvent(int32 event);
static bool FindClosestEvent(eEventType type, CVector posn, int32 *event);
- static void ReportCrimeForEvent(eEventType type, int32, bool);
+ static void ReportCrimeForEvent(eEventType type, size_t, bool);
};
extern CEvent gaEvent[NUMEVENTS]; \ No newline at end of file
diff --git a/src/core/FileMgr.cpp b/src/core/FileMgr.cpp
index 1939c861..cdcb80f0 100644
--- a/src/core/FileMgr.cpp
+++ b/src/core/FileMgr.cpp
@@ -163,7 +163,7 @@ myfgets(char *buf, int len, int fd)
return buf;
}
-static int
+static size_t
myfread(void *buf, size_t elt, size_t n, int fd)
{
if(myfiles[fd].isText){
@@ -184,7 +184,7 @@ myfread(void *buf, size_t elt, size_t n, int fd)
return fread(buf, elt, n, myfiles[fd].file);
}
-static int
+static size_t
myfwrite(void *buf, size_t elt, size_t n, int fd)
{
if(myfiles[fd].isText){
@@ -265,11 +265,11 @@ CFileMgr::SetDirMyDocuments(void)
mychdir(_psGetUserFilesFolder());
}
-int
+size_t
CFileMgr::LoadFile(const char *file, uint8 *buf, int unused, const char *mode)
{
int fd;
- int n, len;
+ size_t n, len;
fd = myfopen(file, mode);
if(fd == 0)
@@ -298,14 +298,14 @@ CFileMgr::OpenFileForWriting(const char *file)
return OpenFile(file, "wb");
}
-int
-CFileMgr::Read(int fd, const char *buf, int len)
+size_t
+CFileMgr::Read(int fd, const char *buf, size_t len)
{
return myfread((void*)buf, 1, len, fd);
}
-int
-CFileMgr::Write(int fd, const char *buf, int len)
+size_t
+CFileMgr::Write(int fd, const char *buf, size_t len)
{
return myfwrite((void*)buf, 1, len, fd);
}
diff --git a/src/core/FileMgr.h b/src/core/FileMgr.h
index 1d0faf50..51e30694 100644
--- a/src/core/FileMgr.h
+++ b/src/core/FileMgr.h
@@ -9,12 +9,12 @@ public:
static void ChangeDir(const char *dir);
static void SetDir(const char *dir);
static void SetDirMyDocuments(void);
- static int LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
+ static size_t LoadFile(const char *file, uint8 *buf, int unused, const char *mode);
static int OpenFile(const char *file, const char *mode);
static int OpenFile(const char *file) { return OpenFile(file, "rb"); }
static int OpenFileForWriting(const char *file);
- static int Read(int fd, const char *buf, int len);
- static int Write(int fd, const char *buf, int len);
+ static size_t Read(int fd, const char *buf, size_t len);
+ static size_t Write(int fd, const char *buf, size_t len);
static bool Seek(int fd, int offset, int whence);
static bool ReadLine(int fd, char *buf, int len);
static int CloseFile(int fd);
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index a3b15ac1..e5776459 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -2653,7 +2653,7 @@ CMenuManager::DrawPlayerSetupScreen()
char nameTemp[256];
for (m_pSelectedSkin = m_pSkinListHead.nextSkin; m_pSelectedSkin; m_pSelectedSkin = m_pSelectedSkin->nextSkin) {
// Drop extension
- int oldLength = strlen(m_pSelectedSkin->skinNameDisplayed);
+ int oldLength = (int)strlen(m_pSelectedSkin->skinNameDisplayed);
m_pSelectedSkin->skinNameDisplayed[oldLength - 4] = '\0';
m_pSelectedSkin->skinNameOriginal[oldLength - 4] = '\0';
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index de5881b5..072bc7be 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -362,7 +362,7 @@ bool CGame::Initialise(const char* datFile)
CStreaming::LoadInitialPeds();
CStreaming::RequestBigBuildings(LEVEL_GENERIC);
CStreaming::LoadAllRequestedModels(false);
- printf("Streaming uses %dK of its memory", CStreaming::ms_memoryUsed / 1024);
+ printf("Streaming uses %zuK of its memory", CStreaming::ms_memoryUsed / 1024); // original modifier was %d
LoadingScreen("Loading the Game", "Load animations", GetRandomSplashScreen());
CAnimManager::LoadAnimFiles();
CStreaming::LoadInitialWeapons();
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp
index 83930c41..685256e3 100644
--- a/src/core/Pad.cpp
+++ b/src/core/Pad.cpp
@@ -3028,7 +3028,7 @@ void CPad::ResetCheats(void)
char *CPad::EditString(char *pStr, int32 nSize)
{
- int32 pos = strlen(pStr);
+ int32 pos = (int32)strlen(pStr);
// letters
for ( int32 i = 0; i < ('Z' - 'A' + 1); i++ )
diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp
index 484155d6..3c32b856 100644
--- a/src/core/Streaming.cpp
+++ b/src/core/Streaming.cpp
@@ -44,7 +44,7 @@ int32 CStreaming::ms_oldSectorX;
int32 CStreaming::ms_oldSectorY;
int32 CStreaming::ms_streamingBufferSize;
int8 *CStreaming::ms_pStreamingBuffer[2];
-int32 CStreaming::ms_memoryUsed;
+size_t CStreaming::ms_memoryUsed;
CStreamingChannel CStreaming::ms_channel[2];
int32 CStreaming::ms_channelError;
int32 CStreaming::ms_numVehiclesLoaded;
@@ -61,7 +61,7 @@ uint16 CStreaming::ms_loadedGangCars;
int32 CStreaming::ms_imageOffsets[NUMCDIMAGES];
int32 CStreaming::ms_lastImageRead;
int32 CStreaming::ms_imageSize;
-uint32 CStreaming::ms_memoryAvailable;
+size_t CStreaming::ms_memoryAvailable;
int32 desiredNumVehiclesLoaded = 12;
@@ -200,9 +200,9 @@ CStreaming::Init2(void)
debug("Streaming buffer size is %d sectors", ms_streamingBufferSize);
#define MB (1024*1024)
- ms_memoryAvailable = 65*MB;
+ ms_memoryAvailable = 65 * MB;
desiredNumVehiclesLoaded = 25;
- debug("Memory allocated to Streaming is %dMB", ms_memoryAvailable/MB);
+ debug("Memory allocated to Streaming is %dMB", ms_memoryAvailable / MB);
#undef MB
// find island LODs
@@ -2385,7 +2385,7 @@ CStreaming::DeleteRwObjectsAfterDeath(const CVector &pos)
}
void
-CStreaming::DeleteRwObjectsBehindCamera(int32 mem)
+CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
{
int ix, iy;
int x, y;
@@ -2560,7 +2560,7 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y)
}
bool
-CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
+CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem)
{
CPtrNode *node;
CEntity *e;
@@ -2581,7 +2581,7 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
}
bool
-CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem)
+CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem)
{
CPtrNode *node;
CEntity *e;
@@ -2608,7 +2608,7 @@ CStreaming::MakeSpaceFor(int32 size)
// the code still happens to work in that case because ms_memoryAvailable is unsigned
// but it's not nice....
- while((uint32)ms_memoryUsed >= ms_memoryAvailable - size)
+ while(ms_memoryUsed >= ms_memoryAvailable - size)
if(!RemoveLeastUsedModel(STREAMFLAGS_20)){
DeleteRwObjectsBehindCamera(ms_memoryAvailable - size);
return;
@@ -2699,7 +2699,8 @@ CStreaming::UpdateForAnimViewer(void)
if (CStreaming::ms_channelError == -1) {
CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f));
CStreaming::LoadRequestedModels();
- sprintf(gString, "Requested %d, memory size %dK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);
+ // original modifier was %d
+ sprintf(gString, "Requested %d, memory size %zuK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);
}
else {
CStreaming::RetryLoadFile(CStreaming::ms_channelError);
diff --git a/src/core/Streaming.h b/src/core/Streaming.h
index 8a92266f..569c06d8 100644
--- a/src/core/Streaming.h
+++ b/src/core/Streaming.h
@@ -89,7 +89,7 @@ public:
static int32 ms_oldSectorY;
static int32 ms_streamingBufferSize;
static int8 *ms_pStreamingBuffer[2];
- static int32 ms_memoryUsed;
+ static size_t ms_memoryUsed;
static CStreamingChannel ms_channel[2];
static int32 ms_channelError;
static int32 ms_numVehiclesLoaded;
@@ -106,7 +106,7 @@ public:
static int32 ms_imageOffsets[NUMCDIMAGES];
static int32 ms_lastImageRead;
static int32 ms_imageSize;
- static uint32 ms_memoryAvailable;
+ static size_t ms_memoryAvailable;
static void Init(void);
static void Init2(void);
@@ -193,11 +193,11 @@ public:
static void DeleteFarAwayRwObjects(const CVector &pos);
static void DeleteAllRwObjects(void);
static void DeleteRwObjectsAfterDeath(const CVector &pos);
- static void DeleteRwObjectsBehindCamera(int32 mem);
+ static void DeleteRwObjectsBehindCamera(size_t mem);
static void DeleteRwObjectsInSectorList(CPtrList &list);
static void DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y);
- static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem);
- static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem);
+ static bool DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem);
+ static bool DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem);
static void LoadScene(const CVector &pos);
static void LoadSceneCollision(const CVector &pos);
diff --git a/src/core/common.h b/src/core/common.h
index 3ead4f1d..b3ba757d 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -17,7 +17,11 @@
#if defined _WIN32 && defined WITHD3D
#include <windows.h>
+#ifndef USE_D3D9
#include <d3d8types.h>
+#else
+#include <d3d9types.h>
+#endif
#endif
#include <rwcore.h>
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 7db2124d..53c2b2c2 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -5637,7 +5637,7 @@ CPed::LoadFightData(void)
CAnimBlendAssociation *animAssoc;
- int bp, buflen;
+ size_t bp, buflen;
int lp, linelen;
buflen = CFileMgr::LoadFile("DATA\\fistfite.dat", work_buff, sizeof(work_buff), "r");
diff --git a/src/peds/PedAttractor.cpp b/src/peds/PedAttractor.cpp
index db5f9e52..d69f2684 100644
--- a/src/peds/PedAttractor.cpp
+++ b/src/peds/PedAttractor.cpp
@@ -137,8 +137,8 @@ void CPedAttractorManager::RemoveIceCreamVanEffects(C2dEffect* pEffect)
for (std::vector<CVehicleToEffect>::const_iterator assoc = vVehicleToEffect.cbegin(); assoc != vVehicleToEffect.cend();) {
if (assoc->GetVehicle() != pVehicle)
return;
- size_t total = 0;
- for (size_t j = 0; j < NUM_ATTRACTORS_FOR_ICECREAM_VAN; j++) {
+ int total = 0;
+ for (int j = 0; j < NUM_ATTRACTORS_FOR_ICECREAM_VAN; j++) {
if (FindAssociatedAttractor(assoc->GetEffect(j), vIceCreamAttractors))
total++;
}
@@ -355,13 +355,13 @@ bool CPedAttractor::BroadcastArrival(CPed* pPed)
bool CPedAttractor::BroadcastDeparture(CPed* pPed)
{
int qid = -1;
- for (size_t i = 0; i < vWaitingQueue.size(); i++){
+ for (int i = 0; i < vWaitingQueue.size(); i++){
if (vWaitingQueue[i] == pPed)
qid = i;
}
if (qid < 0)
return false;
- for (size_t i = qid + 1; i < vWaitingQueue.size(); i++) {
+ for (int i = qid + 1; i < vWaitingQueue.size(); i++) {
CVector pos;
float heading;
float time;
@@ -401,7 +401,7 @@ bool CPedAttractor::BroadcastDeparture(CPed* pPed)
bool CPedShelterAttractor::BroadcastDeparture(CPed* pPed)
{
int qid = -1;
- for (size_t i = 0; i < vWaitingQueue.size(); i++) {
+ for (int i = 0; i < vWaitingQueue.size(); i++) {
if (vWaitingQueue[i] == pPed)
qid = i;
}
diff --git a/src/peds/PedAttractor.h b/src/peds/PedAttractor.h
index 563efd3a..85b4327b 100644
--- a/src/peds/PedAttractor.h
+++ b/src/peds/PedAttractor.h
@@ -108,8 +108,8 @@ public:
float ComputeDeltaHeading() const;
float ComputeDeltaPos() const;
void ComputeAttractTime(int32 id, bool, float& time) const;
- int32 GetNoOfRegisteredPeds() const { return vWaitingQueue.size() + vApproachingQueue.size(); }
- int32 ComputeFreeSlot() const { return vWaitingQueue.size(); }
+ int32 GetNoOfRegisteredPeds() const { return (int32)(vWaitingQueue.size() + vApproachingQueue.size()); }
+ int32 ComputeFreeSlot() const { return (int32)vWaitingQueue.size(); }
bool IsInQueue(CPed*) const;
bool RegisterPed(CPed*);
bool BroadcastArrival(CPed*);
diff --git a/src/peds/PedStats.cpp b/src/peds/PedStats.cpp
index 06e39039..1f7a95b4 100644
--- a/src/peds/PedStats.cpp
+++ b/src/peds/PedStats.cpp
@@ -47,7 +47,7 @@ CPedStats::LoadPedStats(void)
char *buf;
char line[256];
char name[32];
- int bp, buflen;
+ size_t bp, buflen;
int lp, linelen;
int type;
float fleeDist, headingChangeRate, attackStrength, defendWeakness;
diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp
index 8bf4c6e1..397cd71d 100644
--- a/src/peds/PedType.cpp
+++ b/src/peds/PedType.cpp
@@ -43,7 +43,7 @@ CPedType::LoadPedData(void)
char *buf;
char line[256];
char word[32];
- int bp, buflen;
+ size_t bp, buflen;
int lp, linelen;
int type;
uint32 flags;
diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp
index fc6e6853..4771d8a4 100644
--- a/src/render/Fluff.cpp
+++ b/src/render/Fluff.cpp
@@ -922,7 +922,7 @@ void CScrollBar::Update()
break;
}
- m_MessageLength = strlen(m_pMessage);
+ m_MessageLength = (uint32)strlen(m_pMessage);
m_MessageCurrentChar = 0;
}
diff --git a/src/rw/NodeName.cpp b/src/rw/NodeName.cpp
index d62884f7..ad4acffb 100644
--- a/src/rw/NodeName.cpp
+++ b/src/rw/NodeName.cpp
@@ -51,7 +51,7 @@ RwInt32
NodeNameStreamGetSize(const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
// game checks for null pointer on node name extension but that really happen
- return rwstrlen(NODENAMEEXT(object));
+ return (RwInt32)rwstrlen(NODENAMEEXT(object));
}
bool
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index 25dffb4e..ac80eff0 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -843,12 +843,12 @@ CVisibilityPlugins::FrameCopyConstructor(void *dst, const void *src, int32, int3
}
void
-CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, int32 id)
+CVisibilityPlugins::SetFrameHierarchyId(RwFrame *frame, uintptr id)
{
FRAMEEXT(frame)->id = id;
}
-int32
+uintptr
CVisibilityPlugins::GetFrameHierarchyId(RwFrame *frame)
{
return FRAMEEXT(frame)->id;
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index d426abec..f277565d 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -112,10 +112,10 @@ public:
struct FrameExt
{
// BUG: this is abused to hold a pointer by SetClumpModelInfo
- int32 id;
+ uintptr id;
};
- static void SetFrameHierarchyId(RwFrame *frame, int32 id);
- static int32 GetFrameHierarchyId(RwFrame *frame);
+ static void SetFrameHierarchyId(RwFrame *frame, uintptr id);
+ static uintptr GetFrameHierarchyId(RwFrame *frame);
static void *FrameConstructor(void *object, int32 offset, int32 len);
static void *FrameDestructor(void *object, int32 offset, int32 len);
diff --git a/src/skel/crossplatform.h b/src/skel/crossplatform.h
index a21877c1..678d3ec4 100644
--- a/src/skel/crossplatform.h
+++ b/src/skel/crossplatform.h
@@ -4,7 +4,7 @@
// Functions that's different on glfw and win but have same signature, should be located on platform.h.
#ifdef _WIN32
-// This only has <windef.h> as Win header.
+// This only has <windef.h> as Windows header, which is lighter (as long as WITHWINDOWS isn't defined / <Windows.h> isn't included).
#include "win.h"
extern DWORD _dwOperatingSystemVersion;
#else
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index 8b479681..a0a5a171 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -63,7 +63,7 @@ static psGlobalType PsGlobal;
#undef MAKEPOINTS
#define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l)))
-unsigned long _dwMemAvailPhys;
+size_t _dwMemAvailPhys;
RwUInt32 gGameState;
#ifdef _WIN32
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 93f9b8f2..f8e5c38e 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -19,7 +19,12 @@
#pragma warning( push )
#pragma warning( disable : 4005)
+
+#ifdef USE_D3D9
+#include <d3d9.h>
+#else
#include <d3d8.h>
+#endif
#include <ddraw.h>
#include <dinput.h>
#include <DShow.h>
@@ -27,7 +32,9 @@
#define WM_GRAPHNOTIFY WM_USER+13
+#ifndef USE_D3D9
#pragma comment( lib, "d3d8.lib" )
+#endif
#pragma comment( lib, "ddraw.lib" )
#pragma comment( lib, "Winmm.lib" )
#pragma comment( lib, "dxguid.lib" )
@@ -102,7 +109,7 @@ IMediaSeeking *pMS = nil;
DWORD dwDXVersion;
SIZE_T _dwMemTotalPhys;
-SIZE_T _dwMemAvailPhys;
+size_t _dwMemAvailPhys;
SIZE_T _dwMemTotalVirtual;
SIZE_T _dwMemAvailVirtual;
DWORD _dwMemTotalVideo;
@@ -453,6 +460,16 @@ DWORD GetDXVersion()
dwDXVersion = 0x700;
pDD7->Release();
+#ifdef USE_D3D9
+ HINSTANCE hD3D9DLL = LoadLibrary("D3D9.DLL");
+ if (hD3D9DLL != nil) {
+ FreeLibrary(hDDrawDLL);
+ FreeLibrary(hD3D9DLL);
+
+ dwDXVersion = 0x900;
+ return dwDXVersion;
+ }
+#endif
//-------------------------------------------------------------------------
// DirectX 8.0 Checks
@@ -502,6 +519,7 @@ DWORD GetDXVersion()
/*
*****************************************************************************
*/
+#ifndef _WIN64
static char cpuvendor[16] = "UnknownVendr";
__declspec(naked) const char * _psGetCpuVendr()
{
@@ -575,6 +593,7 @@ void _psPrintCpuInfo()
if ( FeaturesEx & 0x80000000 )
debug("with 3DNow");
}
+#endif
/*
*****************************************************************************
@@ -650,9 +669,9 @@ psInitialize(void)
gGameState = GS_START_UP;
TRACE("gGameState = GS_START_UP");
-
+#ifndef _WIN64
_psPrintCpuInfo();
-
+#endif
OSVERSIONINFO verInfo;
verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -1298,8 +1317,11 @@ RwBool IsForegroundApp()
UINT GetBestRefreshRate(UINT width, UINT height, UINT depth)
{
+#ifdef USE_D3D9
+ LPDIRECT3D9 d3d = Direct3DCreate9(D3D_SDK_VERSION);
+#else
LPDIRECT3D8 d3d = Direct3DCreate8(D3D_SDK_VERSION);
-
+#endif
ASSERT(d3d != nil);
UINT refreshRate = INT_MAX;
@@ -1312,14 +1334,21 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth)
else
format = D3DFMT_R5G6B5;
+#ifdef USE_D3D9
+ UINT modeCount = d3d->GetAdapterModeCount(GcurSel, format);
+#else
UINT modeCount = d3d->GetAdapterModeCount(GcurSel);
-
+#endif
+
for ( UINT i = 0; i < modeCount; i++ )
{
D3DDISPLAYMODE mode;
+#ifdef USE_D3D9
+ d3d->EnumAdapterModes(GcurSel, format, i, &mode);
+#else
d3d->EnumAdapterModes(GcurSel, i, &mode);
-
+#endif
if ( mode.Width == width && mode.Height == height && mode.Format == format )
{
if ( mode.RefreshRate == 0 )
@@ -1612,7 +1641,7 @@ CommandLineToArgv(RwChar *cmdLine, RwInt32 *argCount)
RwInt32 i, len;
RwChar *res, *str, **aptr;
- len = strlen(cmdLine);
+ len = (int)strlen(cmdLine);
/*
* Count the number of arguments...
@@ -1700,11 +1729,11 @@ void InitialiseLanguage()
{
WORD primUserLCID = PRIMARYLANGID(GetSystemDefaultLCID());
WORD primSystemLCID = PRIMARYLANGID(GetUserDefaultLCID());
- WORD primLayout = PRIMARYLANGID((DWORD)GetKeyboardLayout(0));
+ WORD primLayout = PRIMARYLANGID((DWORD_PTR)GetKeyboardLayout(0));
WORD subUserLCID = SUBLANGID(GetSystemDefaultLCID());
WORD subSystemLCID = SUBLANGID(GetUserDefaultLCID());
- WORD subLayout = SUBLANGID((DWORD)GetKeyboardLayout(0));
+ WORD subLayout = SUBLANGID((DWORD_PTR)GetKeyboardLayout(0));
if ( primUserLCID == LANG_GERMAN
|| primSystemLCID == LANG_GERMAN
diff --git a/src/skel/win/win.h b/src/skel/win/win.h
index eb32cb72..9427822d 100644
--- a/src/skel/win/win.h
+++ b/src/skel/win/win.h
@@ -9,8 +9,12 @@
#endif /* (!defined(RSREGSETBREAKALLOC)) */
#ifndef _INC_WINDOWS
-#define _X86_
-#include <windef.h>
+ #ifdef _WIN64
+ #define _AMD64_
+ #else
+ #define _X86_
+ #endif
+ #include <windef.h>
#endif
enum eWinVersion
diff --git a/src/text/Text.cpp b/src/text/Text.cpp
index d954470f..dab1cae3 100644
--- a/src/text/Text.cpp
+++ b/src/text/Text.cpp
@@ -28,7 +28,7 @@ void
CText::Load(void)
{
char filename[32];
- uint32 offset;
+ size_t offset;
int file;
bool tkey_loaded = false, tdat_loaded = false;
ChunkHeader m_ChunkHeader;
@@ -209,7 +209,7 @@ CText::GetNameOfLoadedMissionText(char *outName)
//--MIAMI: DONE
void
-CText::ReadChunkHeader(ChunkHeader *buf, int32 file, uint32 *offset)
+CText::ReadChunkHeader(ChunkHeader *buf, int32 file, size_t *offset)
{
// original code loops 8 times to read 1 byte with CFileMgr::Read, that's retarded
CFileMgr::Read(file, (char*)buf, sizeof(ChunkHeader));
@@ -281,15 +281,15 @@ CText::LoadMissionText(char *MissionTableName)
bool tkey_loaded = false, tdat_loaded = false;
ChunkHeader m_ChunkHeader;
while (!tkey_loaded || !tdat_loaded) {
- uint32 bytes_read = 0;
+ size_t bytes_read = 0;
ReadChunkHeader(&m_ChunkHeader, file, &bytes_read);
if (m_ChunkHeader.size != 0) {
if (strncmp(m_ChunkHeader.magic, "TKEY", 4) == 0) {
- uint32 bytes_read = 0;
+ size_t bytes_read = 0;
mission_keyArray.Load(m_ChunkHeader.size, file, &bytes_read);
tkey_loaded = true;
} else if (strncmp(m_ChunkHeader.magic, "TDAT", 4) == 0) {
- uint32 bytes_read = 0;
+ size_t bytes_read = 0;
mission_data.Load(m_ChunkHeader.size, file, &bytes_read);
tdat_loaded = true;
} else
@@ -308,11 +308,12 @@ CText::LoadMissionText(char *MissionTableName)
//--MIAMI: DONE
void
-CKeyArray::Load(uint32 length, int file, uint32 *offset)
+CKeyArray::Load(size_t length, int file, size_t* offset)
{
char *rawbytes;
- numEntries = length / sizeof(CKeyEntry);
+ // You can make numEntries size_t if you want to exceed 32-bit boundaries, everything else should be ready.
+ numEntries = (int)(length / sizeof(CKeyEntry));
entries = new CKeyEntry[numEntries];
rawbytes = (char*)entries;
@@ -403,11 +404,12 @@ CKeyArray::Search(const char *key, uint8 *result)
//--MIAMI: DONE
void
-CData::Load(uint32 length, int file, uint32 *offset)
+CData::Load(size_t length, int file, size_t * offset)
{
char *rawbytes;
- numChars = length / sizeof(wchar);
+ // You can make numChars size_t if you want to exceed 32-bit boundaries, everything else should be ready.
+ numChars = (int)(length / sizeof(wchar));
chars = new wchar[numChars];
rawbytes = (char*)chars;
@@ -430,10 +432,12 @@ CData::Unload(void)
//--MIAMI: DONE
void
-CMissionTextOffsets::Load(uint32 table_size, int file, uint32 *offset, int)
+CMissionTextOffsets::Load(size_t table_size, int file, size_t *offset, int)
{
// not exact VC code but smaller and better :P
- size = table_size / sizeof(CMissionTextOffsets::Entry);
+
+ // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready.
+ size = (uint16) (table_size / sizeof(CMissionTextOffsets::Entry));
CFileMgr::Read(file, (char*)data, sizeof(CMissionTextOffsets::Entry) * size);
*offset += sizeof(CMissionTextOffsets::Entry) * size;
}
diff --git a/src/text/Text.h b/src/text/Text.h
index 5fa3d0dc..d163b9c9 100644
--- a/src/text/Text.h
+++ b/src/text/Text.h
@@ -26,11 +26,11 @@ class CKeyArray
{
public:
CKeyEntry *entries;
- int numEntries;
+ int numEntries; // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready.
CKeyArray(void) : entries(nil), numEntries(0) {}
~CKeyArray(void) { Unload(); }
- void Load(uint32 length, int file, uint32 *offset);
+ void Load(size_t length, int file, size_t *offset);
void Unload(void);
void Update(wchar *chars);
CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high);
@@ -45,11 +45,11 @@ class CData
{
public:
wchar *chars;
- int numChars;
+ int numChars; // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready.
CData(void) : chars(nil), numChars(0) {}
~CData(void) { Unload(); }
- void Load(uint32 length, int file, uint32 *offset);
+ void Load(size_t length, int file, size_t* offset);
void Unload(void);
};
@@ -65,10 +65,10 @@ public:
enum {MAX_MISSION_TEXTS = 90}; // beware that LCS has more
Entry data[MAX_MISSION_TEXTS];
- uint16 size;
+ uint16 size; // You can make this size_t if you want to exceed 32-bit boundaries, everything else should be ready.
CMissionTextOffsets(void) : size(0) {}
- void Load(uint32 table_size, int file, uint32* bytes_read, int);
+ void Load(size_t table_size, int file, size_t* bytes_read, int);
};
struct ChunkHeader
@@ -96,7 +96,7 @@ public:
wchar GetUpperCase(wchar c);
void UpperCase(wchar *s);
void GetNameOfLoadedMissionText(char *outName);
- void ReadChunkHeader(ChunkHeader *buf, int32 file, uint32 *bytes_read);
+ void ReadChunkHeader(ChunkHeader *buf, int32 file, size_t *bytes_read);
void LoadMissionText(char *MissionTableName);
};
diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp
index bd53d8c5..0f71aeda 100644
--- a/src/weapons/WeaponInfo.cpp
+++ b/src/weapons/WeaponInfo.cpp
@@ -114,7 +114,7 @@ CWeaponInfo::LoadWeaponData(void)
char line[256], weaponName[32], fireType[32];
char animToPlay[32];
- int bp, buflen;
+ size_t bp, buflen;
int lp, linelen;
CFileMgr::SetDir("DATA");