* more fixes for gcc. thx shlainn!
This commit is contained in:
parent
12045179e4
commit
a8ad601dca
@ -173,7 +173,7 @@ DefReturnResult DefScriptPackage::func_setscriptpermission(CmdSet& Set)
|
|||||||
if(Set.defaultarg.empty() || Set.arg[0].empty())
|
if(Set.defaultarg.empty() || Set.arg[0].empty())
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg.c_str());
|
scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,13 +13,27 @@
|
|||||||
|
|
||||||
std::string DefScriptTools::stringToLower(std::string s)
|
std::string DefScriptTools::stringToLower(std::string s)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), std::tolower);
|
std::transform(s.begin(), s.end(), s.begin(), tolower);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DefScriptTools::stringToUpper(std::string s)
|
std::string DefScriptTools::stringToUpper(std::string s)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), std::toupper);
|
std::transform(s.begin(), s.end(), s.begin(), toupper);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DefScriptTools::toString(ldbl num)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss.setf(std::ios_base::fixed);
|
||||||
|
ss.precision(15);
|
||||||
|
ss << Round(num,15);
|
||||||
|
std::string s(ss.str());
|
||||||
|
while(s[s.length()-1]=='0')
|
||||||
|
s.erase(s.length()-1,1);
|
||||||
|
if(s[s.length()-1]=='.')
|
||||||
|
s.erase(s.length()-1,1);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +43,7 @@ std::string DefScriptTools::stringToUpper(std::string s)
|
|||||||
// hex numbers: 0xa56ff, 0XFF, 0xDEADBABE, etc (must begin with 0x)
|
// hex numbers: 0xa56ff, 0XFF, 0xDEADBABE, etc (must begin with 0x)
|
||||||
// float numbers: 99.65, 0.025
|
// float numbers: 99.65, 0.025
|
||||||
// negative numbers: -100, -0x3d, -55.123
|
// negative numbers: -100, -0x3d, -55.123
|
||||||
ldbl DefScriptTools::toNumber(std::string str)
|
ldbl DefScriptTools::toNumber(std::string& str)
|
||||||
{
|
{
|
||||||
ldbl num=0;
|
ldbl num=0;
|
||||||
uint64 u=0;
|
uint64 u=0;
|
||||||
@ -61,7 +75,7 @@ ldbl DefScriptTools::toNumber(std::string str)
|
|||||||
u|=lobits;
|
u|=lobits;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
u = atoi64(str.c_str());
|
u = atoi64(str);
|
||||||
|
|
||||||
if(ppos!=std::string::npos)
|
if(ppos!=std::string::npos)
|
||||||
{
|
{
|
||||||
@ -70,7 +84,7 @@ ldbl DefScriptTools::toNumber(std::string str)
|
|||||||
num=(ldbl)atof(mantissa.c_str());
|
num=(ldbl)atof(mantissa.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
num=(unsigned long double)num + u;
|
num=(long double)num + u;
|
||||||
num=Round(num,10);
|
num=Round(num,10);
|
||||||
|
|
||||||
|
|
||||||
@ -79,14 +93,14 @@ ldbl DefScriptTools::toNumber(std::string str)
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefScriptTools::isTrue(std::string s)
|
bool DefScriptTools::isTrue(std::string& s)
|
||||||
{
|
{
|
||||||
if(s.empty() || s=="false" || s=="0")
|
if(s.empty() || s=="false" || s=="0")
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 DefScriptTools::toUint64(std::string str)
|
uint64 DefScriptTools::toUint64(std::string& str)
|
||||||
{
|
{
|
||||||
bool negative=false;
|
bool negative=false;
|
||||||
uint64 num = 0;
|
uint64 num = 0;
|
||||||
@ -115,21 +129,20 @@ uint64 DefScriptTools::toUint64(std::string str)
|
|||||||
num|=lobits;
|
num|=lobits;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
num = atoi64(str.c_str());
|
num = atoi64(str);
|
||||||
if(negative)
|
if(negative)
|
||||||
num = (uint64)(-1) - num; // is this correct?
|
num = (uint64)(-1) - num; // is this correct?
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 DefScriptTools::atoi64(const char *str)
|
uint64 DefScriptTools::atoi64(std::string& str)
|
||||||
{
|
{
|
||||||
#if COMPILER == COMPILER_MICROSOFT
|
uint64 l = 0;
|
||||||
__int64 tmp = _atoi64(str);
|
for (size_t i = 0; i < str.size(); i++)
|
||||||
return tmp;
|
{
|
||||||
#else
|
l = l * 10 + str[i] - 48;
|
||||||
#error "Fix Me!"
|
}
|
||||||
//return _atoi64(str);
|
return l;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long double DefScriptTools::Round(long double z,unsigned int n)
|
inline long double DefScriptTools::Round(long double z,unsigned int n)
|
||||||
|
|||||||
@ -7,35 +7,22 @@ namespace DefScriptTools
|
|||||||
{
|
{
|
||||||
std::string stringToUpper(std::string);
|
std::string stringToUpper(std::string);
|
||||||
std::string stringToLower(std::string);
|
std::string stringToLower(std::string);
|
||||||
ldbl toNumber(std::string);
|
std::string toString(ldbl);
|
||||||
bool isTrue(std::string);
|
inline std::string toString(double num) { return toString(ldbl(num)); }
|
||||||
uint64 toUint64(std::string);
|
inline std::string toString(float num) { return toString(ldbl(num)); }
|
||||||
uint64 atoi64(const char*);
|
|
||||||
inline long double Round(long double z,unsigned int n);
|
|
||||||
template <class T> inline std::string toString(T num)
|
template <class T> inline std::string toString(T num)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << num;
|
ss << num;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
template <ldbl> inline std::string toString(ldbl num)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss.setf(std::ios_base::fixed);
|
|
||||||
ss.precision(15);
|
|
||||||
ss << Round(num,15);
|
|
||||||
std::string s(ss.str());
|
|
||||||
while(s[s.length()-1]=='0')
|
|
||||||
s.erase(s.length()-1,1);
|
|
||||||
if(s[s.length()-1]=='.')
|
|
||||||
s.erase(s.length()-1,1);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
template <float> inline std::string toString(float num)
|
|
||||||
{
|
|
||||||
return toString<ldbl>(num);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ldbl toNumber(std::string&);
|
||||||
|
bool isTrue(std::string&);
|
||||||
|
uint64 toUint64(std::string&);
|
||||||
|
uint64 atoi64(std::string&);
|
||||||
|
inline long double Round(long double z,unsigned int n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -100,4 +100,3 @@ void DefScript_DynamicEventMgr::Update(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,16 +173,12 @@ bool VarSet::ReadVarsFromFile(std::string fn)
|
|||||||
|
|
||||||
std::string VarSet::toLower(std::string s)
|
std::string VarSet::toLower(std::string s)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), std::tolower);
|
std::transform(s.begin(), s.end(), s.begin(), tolower);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VarSet::toUpper(std::string s)
|
std::string VarSet::toUpper(std::string s)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), std::toupper);
|
std::transform(s.begin(), s.end(), s.begin(), toupper);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1012,7 +1012,7 @@ DefReturnResult DefScriptPackage::SCGui(CmdSet &Set)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while(!ins->GetGUI() && !ins->GetGUI()->IsInitialized())
|
while(!ins->GetGUI() && !ins->GetGUI()->IsInitialized())
|
||||||
Sleep(1);
|
ins->GetRunnable()->sleep(1);
|
||||||
|
|
||||||
// TODO: not sure if this piece of code will work as intended, needs some testing
|
// TODO: not sure if this piece of code will work as intended, needs some testing
|
||||||
if(ins->GetWSession() && ins->GetWSession()->InWorld())
|
if(ins->GetWSession() && ins->GetWSession()->InWorld())
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "PseuGui.h"
|
#include "PseuGUI.h"
|
||||||
#include "DrawObject.h"
|
#include "DrawObject.h"
|
||||||
#include "PseuWoW.h"
|
#include "PseuWoW.h"
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using namespace video;
|
|||||||
using namespace io;
|
using namespace io;
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
|
|
||||||
class PseuGUI;
|
class PseuGUI;
|
||||||
|
|
||||||
// base class
|
// base class
|
||||||
|
|||||||
@ -208,7 +208,7 @@ void SceneWorld::InitTerrain(void)
|
|||||||
|
|
||||||
mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles
|
mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles
|
||||||
tilesize = UNITSIZE;
|
tilesize = UNITSIZE;
|
||||||
meshsize = CHUNKSIZE*3;
|
meshsize = (s32)CHUNKSIZE*3;
|
||||||
vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here?
|
vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here?
|
||||||
|
|
||||||
camera->setPosition(core::vector3df(mapsize*tilesize/2, 0, mapsize*tilesize/2) + terrainPos);
|
camera->setPosition(core::vector3df(mapsize*tilesize/2, 0, mapsize*tilesize/2) + terrainPos);
|
||||||
@ -300,16 +300,16 @@ void SceneWorld::UpdateTerrain(void)
|
|||||||
highest = max(highest,curheight);
|
highest = max(highest,curheight);
|
||||||
lowest = min(lowest,curheight);
|
lowest = min(lowest,curheight);
|
||||||
}
|
}
|
||||||
f32 heightdiff = highest - lowest;
|
// f32 heightdiff = highest - lowest;
|
||||||
|
|
||||||
// randomize terrain color depending on height
|
// randomize terrain color depending on height
|
||||||
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
||||||
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
||||||
{
|
{
|
||||||
curheight = terrain->getHeight(i,j);
|
curheight = terrain->getHeight(i,j);
|
||||||
u32 g = (curheight / highest * 120) + 125;
|
u32 g = (u32)(curheight / highest * 120) + 125;
|
||||||
u32 r = (curheight / highest * 120) + 60;
|
u32 r = (u32)(curheight / highest * 120) + 60;
|
||||||
u32 b = (curheight / highest * 120) + 60;
|
u32 b = (u32)(curheight / highest * 120) + 60;
|
||||||
|
|
||||||
terrain->setColor(i,j, video::SColor(255,r,g,b));
|
terrain->setColor(i,j, video::SColor(255,r,g,b));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,6 +182,12 @@ ShTlTerrainSceneNode::ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager,
|
|||||||
|
|
||||||
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mmflag);
|
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mmflag);
|
||||||
|
|
||||||
|
// irrlicht 1.4
|
||||||
|
/*
|
||||||
|
Material[0].TextureLayer[1].Texture = CTexture;
|
||||||
|
Material[0].TextureLayer[1].TextureWrap = video::ETC_CLAMP_TO_EDGE;
|
||||||
|
*/
|
||||||
|
// irrlicht 1.3:
|
||||||
Material[0].Textures[1] = CTexture;
|
Material[0].Textures[1] = CTexture;
|
||||||
Material[0].TextureWrap[1] = video::ETC_CLAMP_TO_EDGE;
|
Material[0].TextureWrap[1] = video::ETC_CLAMP_TO_EDGE;
|
||||||
|
|
||||||
|
|||||||
@ -234,7 +234,7 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
|||||||
buf >> proto->Delay;
|
buf >> proto->Delay;
|
||||||
buf >> proto->Ammo_type;
|
buf >> proto->Ammo_type;
|
||||||
|
|
||||||
buf >> (float)proto->RangedModRange;
|
buf >> proto->RangedModRange;
|
||||||
for(int s = 0; s < 5; s++)
|
for(int s = 0; s < 5; s++)
|
||||||
{
|
{
|
||||||
buf >> proto->Spells[s].SpellId;
|
buf >> proto->Spells[s].SpellId;
|
||||||
@ -309,7 +309,7 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 total = session->objmgr.GetItemProtoCount();
|
uint32 total = session->objmgr.GetItemProtoCount();
|
||||||
fh.write((char*)&(uint32)ITEMPROTOTYPES_CACHE_VERSION,4);
|
fh.write((char*)&ITEMPROTOTYPES_CACHE_VERSION,4);
|
||||||
fh.write((char*)&total,4);
|
fh.write((char*)&total,4);
|
||||||
|
|
||||||
uint32 counter=0;
|
uint32 counter=0;
|
||||||
@ -497,7 +497,7 @@ void CreatureTemplateCache_WriteDataToCache(WorldSession *session)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32 total = session->objmgr.GetCreatureTemplateCount();
|
uint32 total = session->objmgr.GetCreatureTemplateCount();
|
||||||
fh.write((char*)&(uint32)CREATURETEMPLATES_CACHE_VERSION,4);
|
fh.write((char*)&CREATURETEMPLATES_CACHE_VERSION,4);
|
||||||
fh.write((char*)&total,4);
|
fh.write((char*)&total,4);
|
||||||
uint32 counter=0;
|
uint32 counter=0;
|
||||||
ByteBuffer buf;
|
ByteBuffer buf;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket)
|
|||||||
recvPacket >> proto->Delay;
|
recvPacket >> proto->Delay;
|
||||||
recvPacket >> proto->Ammo_type;
|
recvPacket >> proto->Ammo_type;
|
||||||
|
|
||||||
recvPacket >> (float)proto->RangedModRange;
|
recvPacket >> proto->RangedModRange;
|
||||||
for(int s = 0; s < 5; s++)
|
for(int s = 0; s < 5; s++)
|
||||||
{
|
{
|
||||||
recvPacket >> proto->Spells[s].SpellId;
|
recvPacket >> proto->Spells[s].SpellId;
|
||||||
|
|||||||
@ -72,5 +72,3 @@ uint16 MyCharacter::GetSpellSlot(uint32 spellid)
|
|||||||
return i->slot;
|
return i->slot;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,3 +71,4 @@ float World::GetPosZ(float x, float y)
|
|||||||
logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)");
|
logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ class ByteBuffer
|
|||||||
|
|
||||||
void append(const std::string& str)
|
void append(const std::string& str)
|
||||||
{
|
{
|
||||||
append((uint8 *)str.c_str(),str.size() + 1);
|
append((const uint8 *)str.c_str(),str.size() + 1);
|
||||||
}
|
}
|
||||||
void append(const char *src, size_t cnt)
|
void append(const char *src, size_t cnt)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -100,6 +100,14 @@
|
|||||||
#define SIGQUIT 3
|
#define SIGQUIT 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef min
|
||||||
|
#undef min
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef max
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
|
|
||||||
#if COMPILER == COMPILER_MICROSOFT
|
#if COMPILER == COMPILER_MICROSOFT
|
||||||
# if _MSC_VER >= 1500
|
# if _MSC_VER >= 1500
|
||||||
# define COMPILER_NAME "VC90"
|
# define COMPILER_NAME "VC90"
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|||||||
@ -290,4 +290,3 @@ void _log_resetcolor(bool stdout_stream)
|
|||||||
fprintf(( stdout_stream ? stdout : stderr ), "\x1b[0m");
|
fprintf(( stdout_stream ? stdout : stderr ), "\x1b[0m");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,4 +37,3 @@ void _log_resetcolor(bool);
|
|||||||
const int Color_count = int(WHITE)+1;
|
const int Color_count = int(WHITE)+1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -12,6 +12,7 @@
|
|||||||
# include <time.h>
|
# include <time.h>
|
||||||
#else
|
#else
|
||||||
# include <sys/dir.h>
|
# include <sys/dir.h>
|
||||||
|
# include <sys/stat.h>
|
||||||
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
|
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
# endif
|
# endif
|
||||||
@ -44,13 +45,13 @@ void printchex(char *in, uint32 len, bool spaces=true)
|
|||||||
|
|
||||||
std::string stringToLower(std::string s)
|
std::string stringToLower(std::string s)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), std::tolower);
|
std::transform(s.begin(), s.end(), s.begin(), tolower);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string stringToUpper(std::string s)
|
std::string stringToUpper(std::string s)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), std::toupper);
|
std::transform(s.begin(), s.end(), s.begin(), toupper);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ bool CreateDir(const char *dir)
|
|||||||
# else
|
# else
|
||||||
// NOT tested for Linux!! whats the return value on success?
|
// NOT tested for Linux!! whats the return value on success?
|
||||||
// TODO: fix me!
|
// TODO: fix me!
|
||||||
result = mkdir(dir);
|
result = mkdir(dir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user