Fixed annoying MSVC bug and MSVC warning spam

develop
Petr Mrázek 2010-02-22 00:18:44 +01:00
parent 9300cc48cc
commit fbad1cb5a3
13 changed files with 42 additions and 25 deletions

@ -25,6 +25,8 @@ distribution.
#ifndef DFCOMMONINTERNAL_H_INCLUDED #ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED #define DFCOMMONINTERNAL_H_INCLUDED
#include <Tranquility.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
@ -36,22 +38,6 @@ using namespace std;
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
/*
#ifdef __KDE_HAVE_GCC_VISIBILITY
#define NO_EXPORT __attribute__ ((visibility("hidden")))
#define EXPORT __attribute__ ((visibility("default")))
#define IMPORT __attribute__ ((visibility("default")))
#elif defined(_WIN32) || defined(_WIN64)
#define NO_EXPORT
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#else
#define NO_EXPORT
#define EXPORT
#define IMPORT
#endif
*/
#ifdef LINUX_BUILD #ifdef LINUX_BUILD
#include <sys/types.h> #include <sys/types.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
@ -116,7 +102,6 @@ namespace DFHack
#define MEMXML_DATA_PATH . #define MEMXML_DATA_PATH .
#endif #endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if defined(_MSC_VER) && _MSC_VER >= 1400
#define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str()) #define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str())
#else #else

@ -271,7 +271,7 @@ bool API::WriteDirtyBit(uint32_t x, uint32_t y, uint32_t z, bool dirtybit)
uint32_t addr_of_struct = g_pProcess->readDWord(addr); uint32_t addr_of_struct = g_pProcess->readDWord(addr);
uint32_t dirtydword = g_pProcess->readDWord(addr_of_struct); uint32_t dirtydword = g_pProcess->readDWord(addr_of_struct);
dirtydword &= 0xFFFFFFF0; dirtydword &= 0xFFFFFFF0;
dirtydword |= dirtybit; dirtydword |= (uint32_t) dirtybit;
g_pProcess->writeDWord (addr_of_struct, dirtydword); g_pProcess->writeDWord (addr_of_struct, dirtydword);
return true; return true;
} }
@ -1036,7 +1036,7 @@ void API::getItemIndexesInBox(vector<uint32_t> &indexes,
uint32_t flags; uint32_t flags;
}; };
temp2 temp2; temp2 temp2;
for(int i =0;i<size;i++){ for(uint32_t i =0;i<size;i++){
uint32_t temp = *(uint32_t *) d->p_itm->at(i); uint32_t temp = *(uint32_t *) d->p_itm->at(i);
g_pProcess->read(temp+sizeof(uint32_t),5 * sizeof(uint16_t), (uint8_t *) &temp2); g_pProcess->read(temp+sizeof(uint32_t),5 * sizeof(uint16_t), (uint8_t *) &temp2);
if(temp2.flags & (1 << 0)){ if(temp2.flags & (1 << 0)){
@ -1097,11 +1097,16 @@ bool API::ReadCreature (const int32_t &index, t_creature & furball)
furball.profession = g_pProcess->readByte (temp + d->creature_profession_offset); furball.profession = g_pProcess->readByte (temp + d->creature_profession_offset);
// current job HACK: the job object isn't cleanly represented here // current job HACK: the job object isn't cleanly represented here
uint32_t jobIdAddr = g_pProcess->readDWord (temp + d->creature_current_job_offset); uint32_t jobIdAddr = g_pProcess->readDWord (temp + d->creature_current_job_offset);
furball.current_job.active = jobIdAddr;
if (jobIdAddr) if (jobIdAddr)
{ {
furball.current_job.active = true;
furball.current_job.jobId = g_pProcess->readByte (jobIdAddr + d->creature_current_job_id_offset); furball.current_job.jobId = g_pProcess->readByte (jobIdAddr + d->creature_current_job_id_offset);
} }
else
{
furball.current_job.active = false;
}
//likes //likes
DfVector likes(d->p->readVector(temp+d->creature_likes_offset,4)); DfVector likes(d->p->readVector(temp+d->creature_likes_offset,4));
@ -1491,7 +1496,7 @@ bool API::ReadPauseState()
assert (d->cursorWindowInited); assert (d->cursorWindowInited);
uint32_t pauseState = g_pProcess->readDWord (d->pause_state_offset); uint32_t pauseState = g_pProcess->readDWord (d->pause_state_offset);
return (pauseState); return pauseState & 1;
} }
uint32_t API::ReadMenuState() uint32_t API::ReadMenuState()

@ -25,6 +25,8 @@ distribution.
#ifndef SIMPLEAPI_H_INCLUDED #ifndef SIMPLEAPI_H_INCLUDED
#define SIMPLEAPI_H_INCLUDED #define SIMPLEAPI_H_INCLUDED
#include <Tranquility.h>
#include "Export.h" #include "Export.h"
#include <string> #include <string>
#include <vector> #include <vector>

@ -25,6 +25,8 @@ distribution.
#ifndef MEMINFO_H_INCLUDED #ifndef MEMINFO_H_INCLUDED
#define MEMINFO_H_INCLUDED #define MEMINFO_H_INCLUDED
#include <Tranquility.h>
#include "Export.h" #include "Export.h"
#include <map> #include <map>
#include <vector> #include <vector>

@ -25,6 +25,8 @@ distribution.
#ifndef MEMINFO_MANAGER_H_INCLUDED #ifndef MEMINFO_MANAGER_H_INCLUDED
#define MEMINFO_MANAGER_H_INCLUDED #define MEMINFO_MANAGER_H_INCLUDED
#include <Tranquility.h>
namespace DFHack namespace DFHack
{ {
class MemInfoManager class MemInfoManager

@ -148,9 +148,6 @@ bool SHMProcess::Private::DF_GetPID(uint32_t & ret)
SHMProcess::SHMProcess(vector <memory_info> & known_versions) SHMProcess::SHMProcess(vector <memory_info> & known_versions)
: d(new Private()) : d(new Private())
{ {
char exe_link_name [256];
char target_name[1024];
int target_result;
// get server and client mutex // get server and client mutex
d->DFSVMutex = OpenMutex(SYNCHRONIZE,false, "DFSVMutex"); d->DFSVMutex = OpenMutex(SYNCHRONIZE,false, "DFSVMutex");
if(d->DFSVMutex == 0) if(d->DFSVMutex == 0)
@ -427,7 +424,6 @@ bool SHMProcess::resume()
bool SHMProcess::attach() bool SHMProcess::attach()
{ {
int status;
if(g_pProcess != 0) if(g_pProcess != 0)
{ {
cerr << "there's already a different process attached" << endl; cerr << "there's already a different process attached" << endl;

@ -25,6 +25,7 @@ distribution.
#ifndef PROCESS_H_INCLUDED #ifndef PROCESS_H_INCLUDED
#define PROCESS_H_INCLUDED #define PROCESS_H_INCLUDED
#include <Tranquility.h>
#include "Export.h" #include "Export.h"
namespace DFHack namespace DFHack
@ -61,6 +62,8 @@ namespace DFHack
class DFHACK_EXPORT Process class DFHACK_EXPORT Process
{ {
public: public:
// this is the single most important destructor ever. ~px
virtual ~Process(){};
// Set up stuff so we can read memory, suspends synchronously // Set up stuff so we can read memory, suspends synchronously
virtual bool attach() = 0; virtual bool attach() = 0;
// detach from DF, resume its execution if it's suspended // detach from DF, resume its execution if it's suspended

@ -25,6 +25,7 @@ distribution.
#ifndef PROCESSMANAGER_H_INCLUDED #ifndef PROCESSMANAGER_H_INCLUDED
#define PROCESSMANAGER_H_INCLUDED #define PROCESSMANAGER_H_INCLUDED
#include <Tranquility.h>
#include "Export.h" #include "Export.h"
class TiXmlElement; class TiXmlElement;

@ -25,6 +25,8 @@ distribution.
#ifndef TILETYPES_H_INCLUDED #ifndef TILETYPES_H_INCLUDED
#define TILETYPES_H_INCLUDED #define TILETYPES_H_INCLUDED
#include <Tranquility.h>
namespace DFHack namespace DFHack
{ {
enum TileClass enum TileClass

@ -25,6 +25,7 @@ distribution.
#ifndef TYPES_H_INCLUDED #ifndef TYPES_H_INCLUDED
#define TYPES_H_INCLUDED #define TYPES_H_INCLUDED
#include <Tranquility.h>
#include "Export.h" #include "Export.h"
namespace DFHack namespace DFHack

@ -24,6 +24,9 @@ distribution.
#ifndef DFVECTOR_H_INCLUDED #ifndef DFVECTOR_H_INCLUDED
#define DFVECTOR_H_INCLUDED #define DFVECTOR_H_INCLUDED
#include <Tranquility.h>
namespace DFHack namespace DFHack
{ {
class DfVector class DfVector

@ -25,6 +25,7 @@ distribution.
#ifndef KEYS_H_INCLUDED #ifndef KEYS_H_INCLUDED
#define KEYS_H_INCLUDED #define KEYS_H_INCLUDED
#include <Tranquility.h>
#include "Export.h" #include "Export.h"
namespace DFHack namespace DFHack

@ -0,0 +1,14 @@
#ifndef DFHACK_TRANQUILITY
#define DFHACK_TRANQUILITY
// This is here to keep MSVC from spamming the build output with nonsense
// Call it public domain.
#ifdef _MSC_VER
// don't spew nonsense
#pragma warning( disable: 4251 )
// don't display bogus 'deprecation' and 'unsafe' warnings
#pragma warning( disable: 4996 )
#endif
#endif