* more fixes for gcc. thx shlainn!

This commit is contained in:
false_genesis 2008-03-24 15:18:26 +00:00
parent 12045179e4
commit a8ad601dca
43 changed files with 506 additions and 498 deletions

View File

@ -173,7 +173,7 @@ DefReturnResult DefScriptPackage::func_setscriptpermission(CmdSet& Set)
if(Set.defaultarg.empty() || Set.arg[0].empty())
return r;
scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg.c_str());
scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg);
return r;
}

View File

@ -13,13 +13,27 @@
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;
}
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;
}
@ -29,7 +43,7 @@ std::string DefScriptTools::stringToUpper(std::string s)
// hex numbers: 0xa56ff, 0XFF, 0xDEADBABE, etc (must begin with 0x)
// float numbers: 99.65, 0.025
// negative numbers: -100, -0x3d, -55.123
ldbl DefScriptTools::toNumber(std::string str)
ldbl DefScriptTools::toNumber(std::string& str)
{
ldbl num=0;
uint64 u=0;
@ -61,7 +75,7 @@ ldbl DefScriptTools::toNumber(std::string str)
u|=lobits;
}
else
u = atoi64(str.c_str());
u = atoi64(str);
if(ppos!=std::string::npos)
{
@ -70,7 +84,7 @@ ldbl DefScriptTools::toNumber(std::string str)
num=(ldbl)atof(mantissa.c_str());
}
num=(unsigned long double)num + u;
num=(long double)num + u;
num=Round(num,10);
@ -79,14 +93,14 @@ ldbl DefScriptTools::toNumber(std::string str)
return num;
}
bool DefScriptTools::isTrue(std::string s)
bool DefScriptTools::isTrue(std::string& s)
{
if(s.empty() || s=="false" || s=="0")
return false;
return true;
}
uint64 DefScriptTools::toUint64(std::string str)
uint64 DefScriptTools::toUint64(std::string& str)
{
bool negative=false;
uint64 num = 0;
@ -115,21 +129,20 @@ uint64 DefScriptTools::toUint64(std::string str)
num|=lobits;
}
else
num = atoi64(str.c_str());
num = atoi64(str);
if(negative)
num = (uint64)(-1) - num; // is this correct?
return num;
}
uint64 DefScriptTools::atoi64(const char *str)
uint64 DefScriptTools::atoi64(std::string& str)
{
#if COMPILER == COMPILER_MICROSOFT
__int64 tmp = _atoi64(str);
return tmp;
#else
#error "Fix Me!"
//return _atoi64(str);
#endif
uint64 l = 0;
for (size_t i = 0; i < str.size(); i++)
{
l = l * 10 + str[i] - 48;
}
return l;
}
inline long double DefScriptTools::Round(long double z,unsigned int n)

View File

@ -7,35 +7,22 @@ namespace DefScriptTools
{
std::string stringToUpper(std::string);
std::string stringToLower(std::string);
ldbl toNumber(std::string);
bool isTrue(std::string);
uint64 toUint64(std::string);
uint64 atoi64(const char*);
inline long double Round(long double z,unsigned int n);
std::string toString(ldbl);
inline std::string toString(double num) { return toString(ldbl(num)); }
inline std::string toString(float num) { return toString(ldbl(num)); }
template <class T> inline std::string toString(T num)
{
std::stringstream ss;
ss << num;
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);
}

View File

@ -100,4 +100,3 @@ void DefScript_DynamicEventMgr::Update(void)
}
}
}

View File

@ -173,16 +173,12 @@ bool VarSet::ReadVarsFromFile(std::string fn)
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;
}
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;
}

View File

@ -1012,7 +1012,7 @@ DefReturnResult DefScriptPackage::SCGui(CmdSet &Set)
return false;
}
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
if(ins->GetWSession() && ins->GetWSession()->InWorld())

View File

@ -1,5 +1,5 @@
#include "common.h"
#include "PseuGui.h"
#include "PseuGUI.h"
#include "DrawObject.h"
#include "PseuWoW.h"

View File

@ -10,6 +10,7 @@ using namespace video;
using namespace io;
using namespace gui;
class PseuGUI;
// base class

View File

@ -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
tilesize = UNITSIZE;
meshsize = CHUNKSIZE*3;
meshsize = (s32)CHUNKSIZE*3;
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);
@ -300,16 +300,16 @@ void SceneWorld::UpdateTerrain(void)
highest = max(highest,curheight);
lowest = min(lowest,curheight);
}
f32 heightdiff = highest - lowest;
// f32 heightdiff = highest - lowest;
// randomize terrain color depending on height
for(s32 j=0; j<terrain->getSize().Height+1; j++)
for(s32 i=0; i<terrain->getSize().Width+1; i++)
{
curheight = terrain->getHeight(i,j);
u32 g = (curheight / highest * 120) + 125;
u32 r = (curheight / highest * 120) + 60;
u32 b = (curheight / highest * 120) + 60;
u32 g = (u32)(curheight / highest * 120) + 125;
u32 r = (u32)(curheight / highest * 120) + 60;
u32 b = (u32)(curheight / highest * 120) + 60;
terrain->setColor(i,j, video::SColor(255,r,g,b));
}

View File

@ -182,6 +182,12 @@ ShTlTerrainSceneNode::ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager,
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].TextureWrap[1] = video::ETC_CLAMP_TO_EDGE;

View File

@ -234,7 +234,7 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
buf >> proto->Delay;
buf >> proto->Ammo_type;
buf >> (float)proto->RangedModRange;
buf >> proto->RangedModRange;
for(int s = 0; s < 5; s++)
{
buf >> proto->Spells[s].SpellId;
@ -309,7 +309,7 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session)
}
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);
uint32 counter=0;
@ -497,7 +497,7 @@ void CreatureTemplateCache_WriteDataToCache(WorldSession *session)
return;
}
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);
uint32 counter=0;
ByteBuffer buf;

View File

@ -60,7 +60,7 @@ void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket)
recvPacket >> proto->Delay;
recvPacket >> proto->Ammo_type;
recvPacket >> (float)proto->RangedModRange;
recvPacket >> proto->RangedModRange;
for(int s = 0; s < 5; s++)
{
recvPacket >> proto->Spells[s].SpellId;

View File

@ -72,5 +72,3 @@ uint16 MyCharacter::GetSpellSlot(uint32 spellid)
return i->slot;
return 0;
}

View File

@ -71,3 +71,4 @@ float World::GetPosZ(float x, float y)
logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)");
return 0;
}

View File

@ -239,7 +239,7 @@ class ByteBuffer
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)
{

View File

@ -100,6 +100,14 @@
#define SIGQUIT 3
#endif
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
#if COMPILER == COMPILER_MICROSOFT
# if _MSC_VER >= 1500
# define COMPILER_NAME "VC90"

View File

@ -9,8 +9,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <string.h>
#include <string>
#include <sstream>
#include <list>
#include <deque>

View File

@ -290,4 +290,3 @@ void _log_resetcolor(bool stdout_stream)
fprintf(( stdout_stream ? stdout : stderr ), "\x1b[0m");
#endif
}

View File

@ -37,4 +37,3 @@ void _log_resetcolor(bool);
const int Color_count = int(WHITE)+1;
#endif

View File

@ -12,6 +12,7 @@
# include <time.h>
#else
# include <sys/dir.h>
# include <sys/stat.h>
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
# include <time.h>
# endif
@ -44,13 +45,13 @@ void printchex(char *in, uint32 len, bool spaces=true)
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;
}
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;
}
@ -171,7 +172,7 @@ bool CreateDir(const char *dir)
# else
// NOT tested for Linux!! whats the return value on success?
// TODO: fix me!
result = mkdir(dir);
result = mkdir(dir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
return result;
}