gcc warning fixes (up to lua files)
This commit is contained in:
parent
7676f739a0
commit
54d985f975
@ -66,7 +66,7 @@
|
||||
return name;
|
||||
}*/
|
||||
|
||||
int update_start(char *data, int len)
|
||||
int update_start(char *data, unsigned int len)
|
||||
{
|
||||
char *self=exe_name(), *temp;
|
||||
#ifdef WIN
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define UPDATE_H_
|
||||
|
||||
//char *exe_name(void);
|
||||
int update_start(char *data, int len);
|
||||
int update_start(char *data, unsigned int len);
|
||||
int update_finish(void);
|
||||
void update_cleanup(void);
|
||||
|
||||
|
@ -345,7 +345,7 @@ bool Client::DoInstallation()
|
||||
#include "icondoc.h"
|
||||
|
||||
std::string filename = exe_name(), pathname = filename.substr(0, filename.rfind('/'));
|
||||
for (int i = 0; i < filename.size(); i++)
|
||||
for (size_t i = 0; i < filename.size(); i++)
|
||||
{
|
||||
if (filename[i] == '\'')
|
||||
{
|
||||
@ -489,7 +489,7 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
||||
#endif
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
while(directoryEntry = readdir(directoryHandle))
|
||||
while ((directoryEntry = readdir(directoryHandle)))
|
||||
{
|
||||
std::string currentFileName = std::string(directoryEntry->d_name);
|
||||
if(currentFileName.length()>4)
|
||||
@ -505,7 +505,7 @@ std::vector<std::string> Client::DirectorySearch(std::string directory, std::str
|
||||
bool extensionMatch = !extensions.size();
|
||||
for(std::vector<std::string>::iterator extIter = extensions.begin(), extEnd = extensions.end(); extIter != extEnd; ++extIter)
|
||||
{
|
||||
int filenameLength = filename.length()-(*extIter).length();
|
||||
size_t filenameLength = filename.length()-(*extIter).length();
|
||||
if(filename.find(*extIter, filenameLength) == filenameLength)
|
||||
{
|
||||
extensionMatch = true;
|
||||
@ -694,7 +694,7 @@ void Client::Tick()
|
||||
|
||||
//Notifications from server
|
||||
json::Array notificationsArray = objDocument["Notifications"];
|
||||
for(int j = 0; j < notificationsArray.Size(); j++)
|
||||
for(size_t j = 0; j < notificationsArray.Size(); j++)
|
||||
{
|
||||
json::String notificationLink = notificationsArray[j]["Link"];
|
||||
json::String notificationText = notificationsArray[j]["Text"];
|
||||
@ -891,7 +891,7 @@ User Client::GetAuthUser()
|
||||
RequestStatus Client::UploadSave(SaveInfo & save)
|
||||
{
|
||||
lastError = "";
|
||||
int gameDataLength;
|
||||
unsigned int gameDataLength;
|
||||
char * gameData = NULL;
|
||||
int dataStatus;
|
||||
char * data;
|
||||
@ -926,7 +926,7 @@ RequestStatus Client::UploadSave(SaveInfo & save)
|
||||
|
||||
const char *const postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL };
|
||||
const char *const postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") };
|
||||
int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 };
|
||||
size_t postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, (size_t)(save.GetPublished()?6:7) };
|
||||
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
||||
data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
|
||||
|
||||
@ -1049,7 +1049,7 @@ std::string Client::AddStamp(GameSave * saveData)
|
||||
|
||||
MakeDirectory(STAMPS_DIR);
|
||||
|
||||
int gameDataLength;
|
||||
unsigned int gameDataLength;
|
||||
char * gameData = saveData->Serialise(gameDataLength);
|
||||
|
||||
std::ofstream stampStream;
|
||||
@ -1089,7 +1089,7 @@ void Client::RescanStamps()
|
||||
if (directory != NULL)
|
||||
{
|
||||
stampIDs.clear();
|
||||
while (entry = readdir(directory))
|
||||
while ((entry = readdir(directory)))
|
||||
{
|
||||
if(strncmp(entry->d_name, "..", 3) && strncmp(entry->d_name, ".", 2) && strstr(entry->d_name, ".stm") && strlen(entry->d_name) == 14)
|
||||
{
|
||||
@ -1110,15 +1110,18 @@ int Client::GetStampsCount()
|
||||
|
||||
std::vector<std::string> Client::GetStamps(int start, int count)
|
||||
{
|
||||
if(start+count > stampIDs.size()) {
|
||||
if(start > stampIDs.size())
|
||||
int size = (int)stampIDs.size();
|
||||
if (start+count > size)
|
||||
{
|
||||
if(start > size)
|
||||
return std::vector<std::string>();
|
||||
count = stampIDs.size()-start;
|
||||
count = size-start;
|
||||
}
|
||||
|
||||
std::vector<std::string> stampRange;
|
||||
int index = 0;
|
||||
for (std::list<std::string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator, ++index) {
|
||||
for (std::list<std::string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator, ++index)
|
||||
{
|
||||
if(index>=start && index < start+count)
|
||||
stampRange.push_back(*iterator);
|
||||
}
|
||||
@ -1149,7 +1152,7 @@ RequestStatus Client::ExecVote(int saveID, int direction)
|
||||
|
||||
const char *const postNames[] = { "ID", "Action", NULL };
|
||||
const char *const postDatas[] = { id, directionText };
|
||||
int postLengths[] = { saveIDText.length(), strlen(directionText) };
|
||||
size_t postLengths[] = { saveIDText.length(), strlen(directionText) };
|
||||
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
||||
data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
|
||||
|
||||
@ -1330,7 +1333,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
|
||||
int dataStatus, dataLength;
|
||||
const char *const postNames[] = { "Username", "Hash", NULL };
|
||||
const char *const postDatas[] = { (char*)username.c_str(), totalHash };
|
||||
int postLengths[] = { username.length(), 32 };
|
||||
size_t postLengths[] = { username.length(), 32 };
|
||||
data = http_multipart_post("http://" SERVER "/Login.json", postNames, postDatas, postLengths, NULL, NULL, NULL, &dataStatus, &dataLength);
|
||||
if(dataStatus == 200 && data)
|
||||
{
|
||||
@ -1350,7 +1353,7 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
|
||||
json::String userElevationTemp = objDocument["Elevation"];
|
||||
|
||||
json::Array notificationsArray = objDocument["Notifications"];
|
||||
for(int j = 0; j < notificationsArray.Size(); j++)
|
||||
for (size_t j = 0; j < notificationsArray.Size(); j++)
|
||||
{
|
||||
json::String notificationLink = notificationsArray[j]["Link"];
|
||||
json::String notificationText = notificationsArray[j]["Text"];
|
||||
@ -1459,7 +1462,7 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
|
||||
|
||||
const char *const postNames[] = { "Comment", NULL };
|
||||
const char *const postDatas[] = { (char*)(comment.c_str()) };
|
||||
int postLengths[] = { comment.length() };
|
||||
size_t postLengths[] = { comment.length() };
|
||||
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
|
||||
}
|
||||
else
|
||||
@ -1575,7 +1578,7 @@ RequestStatus Client::ReportSave(int saveID, std::string message)
|
||||
|
||||
const char *const postNames[] = { "Reason", NULL };
|
||||
const char *const postDatas[] = { (char*)(message.c_str()) };
|
||||
int postLengths[] = { message.length() };
|
||||
size_t postLengths[] = { message.length() };
|
||||
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
|
||||
}
|
||||
else
|
||||
@ -1685,7 +1688,7 @@ RequestStatus Client::PublishSave(int saveID)
|
||||
userIDStream << authUser.ID;
|
||||
const char *const postNames[] = { "ActionPublish", NULL };
|
||||
const char *const postDatas[] = { "" };
|
||||
int postLengths[] = { 1 };
|
||||
size_t postLengths[] = { 1 };
|
||||
char *data = http_multipart_post(urlStream.str().c_str(), postNames, postDatas, postLengths, userIDStream.str().c_str(), NULL, authUser.SessionID.c_str(), &dataStatus, NULL);
|
||||
if (data)
|
||||
free(data);
|
||||
@ -1750,7 +1753,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
|
||||
json::Array tagsArray = objDocument["Tags"];
|
||||
std::list<std::string> tempTags;
|
||||
|
||||
for(int j = 0; j < tagsArray.Size(); j++)
|
||||
for (size_t j = 0; j < tagsArray.Size(); j++)
|
||||
{
|
||||
json::String tempTag = tagsArray[j];
|
||||
tempTags.push_back(tempTag.Value());
|
||||
@ -1826,7 +1829,7 @@ RequestBroker::Request * Client::GetSaveAsync(int saveID, int saveDate)
|
||||
json::Array tagsArray = objDocument["Tags"];
|
||||
std::list<std::string> tempTags;
|
||||
|
||||
for(int j = 0; j < tagsArray.Size(); j++)
|
||||
for (size_t j = 0; j < tagsArray.Size(); j++)
|
||||
{
|
||||
json::String tempTag = tagsArray[j];
|
||||
tempTags.push_back(tempTag.Value());
|
||||
@ -1919,7 +1922,7 @@ RequestBroker::Request * Client::GetCommentsAsync(int saveID, int start, int cou
|
||||
json::Array commentsArray;
|
||||
json::Reader::Read(commentsArray, dataStream);
|
||||
|
||||
for(int j = 0; j < commentsArray.Size(); j++)
|
||||
for (size_t j = 0; j < commentsArray.Size(); j++)
|
||||
{
|
||||
json::Number tempUserID = commentsArray[j]["UserID"];
|
||||
json::String tempUsername = commentsArray[j]["Username"];
|
||||
@ -1972,7 +1975,7 @@ std::vector<SaveComment*> * Client::GetComments(int saveID, int start, int count
|
||||
json::Array commentsArray;
|
||||
json::Reader::Read(commentsArray, dataStream);
|
||||
|
||||
for(int j = 0; j < commentsArray.Size(); j++)
|
||||
for (size_t j = 0; j < commentsArray.Size(); j++)
|
||||
{
|
||||
json::Number tempUserID = commentsArray[j]["UserID"];
|
||||
json::String tempUsername = commentsArray[j]["Username"];
|
||||
@ -2030,7 +2033,7 @@ std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count
|
||||
json::Number tempCount = objDocument["TagTotal"];
|
||||
resultCount = tempCount.Value();
|
||||
json::Array tagsArray = objDocument["Tags"];
|
||||
for(int j = 0; j < tagsArray.Size(); j++)
|
||||
for (size_t j = 0; j < tagsArray.Size(); j++)
|
||||
{
|
||||
json::Number tagCount = tagsArray[j]["Count"];
|
||||
json::String tag = tagsArray[j]["Tag"];
|
||||
@ -2097,7 +2100,7 @@ std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string q
|
||||
json::Number tempCount = objDocument["Count"];
|
||||
resultCount = tempCount.Value();
|
||||
json::Array savesArray = objDocument["Saves"];
|
||||
for(int j = 0; j < savesArray.Size(); j++)
|
||||
for (size_t j = 0; j < savesArray.Size(); j++)
|
||||
{
|
||||
json::Number tempID = savesArray[j]["ID"];
|
||||
json::Number tempDate = savesArray[j]["Date"];
|
||||
@ -2302,7 +2305,7 @@ std::list<std::string> * Client::RemoveTag(int saveID, std::string tag)
|
||||
|
||||
tags = new std::list<std::string>();
|
||||
|
||||
for(int j = 0; j < tagsArray.Size(); j++)
|
||||
for (size_t j = 0; j < tagsArray.Size(); j++)
|
||||
{
|
||||
json::String tempTag = tagsArray[j];
|
||||
tags->push_back(tempTag.Value());
|
||||
@ -2363,7 +2366,7 @@ std::list<std::string> * Client::AddTag(int saveID, std::string tag)
|
||||
|
||||
tags = new std::list<std::string>();
|
||||
|
||||
for(int j = 0; j < tagsArray.Size(); j++)
|
||||
for (size_t j = 0; j < tagsArray.Size(); j++)
|
||||
{
|
||||
json::String tempTag = tagsArray[j];
|
||||
tags->push_back(tempTag.Value());
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
std::string lastError;
|
||||
|
||||
std::list<std::string> stampIDs;
|
||||
int lastStampTime;
|
||||
unsigned lastStampTime;
|
||||
int lastStampName;
|
||||
|
||||
//Auth session
|
||||
|
@ -18,16 +18,16 @@ GameSave::GameSave(GameSave & save) :
|
||||
waterEEnabled(save.waterEEnabled),
|
||||
legacyEnable(save.legacyEnable),
|
||||
gravityEnable(save.gravityEnable),
|
||||
aheatEnable(save.aheatEnable),
|
||||
paused(save.paused),
|
||||
gravityMode(save.gravityMode),
|
||||
aheatEnable(save.aheatEnable),
|
||||
airMode(save.airMode),
|
||||
edgeMode(save.edgeMode),
|
||||
signs(save.signs),
|
||||
palette(save.palette),
|
||||
expanded(save.expanded),
|
||||
hasOriginalData(save.hasOriginalData),
|
||||
originalData(save.originalData),
|
||||
palette(save.palette)
|
||||
originalData(save.originalData)
|
||||
{
|
||||
blockMap = NULL;
|
||||
blockMapPtr = NULL;
|
||||
@ -288,14 +288,14 @@ void GameSave::setSize(int newWidth, int newHeight)
|
||||
|
||||
std::vector<char> GameSave::Serialise()
|
||||
{
|
||||
int dataSize;
|
||||
unsigned int dataSize;
|
||||
char * data = Serialise(dataSize);
|
||||
std::vector<char> dataVect(data, data+dataSize);
|
||||
delete[] data;
|
||||
return dataVect;
|
||||
}
|
||||
|
||||
char * GameSave::Serialise(int & dataSize)
|
||||
char * GameSave::Serialise(unsigned int & dataSize)
|
||||
{
|
||||
return serialiseOPS(dataSize);
|
||||
}
|
||||
@ -304,7 +304,7 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
|
||||
{
|
||||
if(Collapsed())
|
||||
Expand();
|
||||
int i, x, y, nx, ny, width = blockWidth*CELL, height = blockHeight*CELL, newWidth, newHeight, newBlockWidth, newBlockHeight;
|
||||
int x, y, nx, ny, width = blockWidth*CELL, height = blockHeight*CELL, newWidth, newHeight, newBlockWidth, newBlockHeight;
|
||||
vector2d pos, tmp, ctl, cbr, vel;
|
||||
vector2d cornerso[4];
|
||||
// undo any translation caused by rotation
|
||||
@ -312,7 +312,7 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
|
||||
cornerso[1] = v2d_new(width-1,0);
|
||||
cornerso[2] = v2d_new(0,height-1);
|
||||
cornerso[3] = v2d_new(width-1,height-1);
|
||||
for (i=0; i<4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
tmp = m2d_multiply_v2d(transform,cornerso[i]);
|
||||
if (i==0) ctl = cbr = tmp; // top left, bottom right corner
|
||||
@ -357,7 +357,7 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
|
||||
fanVelYNew[y] = &fanVelYPtrNew[y*newBlockWidth];
|
||||
|
||||
// rotate and translate signs, parts, walls
|
||||
for (i=0; i < signs.size(); i++)
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
pos = v2d_new(signs[i].x, signs[i].y);
|
||||
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
|
||||
@ -371,7 +371,7 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
|
||||
signs[i].x = nx;
|
||||
signs[i].y = ny;
|
||||
}
|
||||
for (i=0; i<particlesCount; i++)
|
||||
for (int i = 0; i < particlesCount; i++)
|
||||
{
|
||||
if (!particles[i].type) continue;
|
||||
pos = v2d_new(particles[i].x, particles[i].y);
|
||||
@ -437,9 +437,8 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
unsigned char * inputData = (unsigned char*)data, *bsonData = NULL, *partsData = NULL, *partsPosData = NULL, *fanData = NULL, *wallData = NULL, *soapLinkData = NULL;
|
||||
unsigned int inputDataLen = dataLength, bsonDataLen = 0, partsDataLen, partsPosDataLen, fanDataLen, wallDataLen, soapLinkDataLen;
|
||||
unsigned partsCount = 0, *partsSimIndex = NULL;
|
||||
int i, x, y, j;
|
||||
int *freeIndices = NULL;
|
||||
int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
|
||||
unsigned int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
|
||||
int savedVersion = inputData[4];
|
||||
bson b;
|
||||
bson_iterator iter;
|
||||
@ -717,15 +716,15 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
//Read wall and fan data
|
||||
if(wallData)
|
||||
{
|
||||
j = 0;
|
||||
if(blockW * blockH > wallDataLen)
|
||||
unsigned int j = 0;
|
||||
if (blockW * blockH > wallDataLen)
|
||||
{
|
||||
fprintf(stderr, "Not enough wall data\n");
|
||||
goto fail;
|
||||
}
|
||||
for(x = 0; x < blockW; x++)
|
||||
for (unsigned int x = 0; x < blockW; x++)
|
||||
{
|
||||
for(y = 0; y < blockH; y++)
|
||||
for (unsigned int y = 0; y < blockH; y++)
|
||||
{
|
||||
if (wallData[y*blockW+x])
|
||||
blockMap[blockY+y][blockX+x] = wallData[y*blockW+x];
|
||||
@ -780,12 +779,11 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
}
|
||||
|
||||
//Read particle data
|
||||
if(partsData && partsPosData)
|
||||
if (partsData && partsPosData)
|
||||
{
|
||||
int newIndex = 0, fieldDescriptor, tempTemp;
|
||||
int posCount, posTotal, partsPosDataIndex = 0;
|
||||
int saved_x, saved_y;
|
||||
if(fullW * fullH * 3 > partsPosDataLen)
|
||||
if (fullW * fullH * 3 > partsPosDataLen)
|
||||
{
|
||||
fprintf(stderr, "Not enough particle position data\n");
|
||||
goto fail;
|
||||
@ -794,11 +792,12 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
partsSimIndex = (unsigned int*)calloc(NPART, sizeof(unsigned));
|
||||
partsCount = 0;
|
||||
|
||||
i = 0;
|
||||
unsigned int i = 0;
|
||||
unsigned int saved_x, saved_y, x, y;
|
||||
newIndex = 0;
|
||||
for (saved_y=0; saved_y<fullH; saved_y++)
|
||||
for (saved_y = 0; saved_y < fullH; saved_y++)
|
||||
{
|
||||
for (saved_x=0; saved_x<fullW; saved_x++)
|
||||
for (saved_x = 0; saved_x < fullW; saved_x++)
|
||||
{
|
||||
//Read total number of particles at this position
|
||||
posTotal = 0;
|
||||
@ -806,10 +805,10 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
posTotal |= partsPosData[partsPosDataIndex++]<<8;
|
||||
posTotal |= partsPosData[partsPosDataIndex++];
|
||||
//Put the next posTotal particles at this position
|
||||
for (posCount=0; posCount<posTotal; posCount++)
|
||||
for (posCount = 0; posCount < posTotal; posCount++)
|
||||
{
|
||||
particlesCount = newIndex+1;
|
||||
if(newIndex>=NPART)
|
||||
if (newIndex >= NPART)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
@ -821,15 +820,15 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
y = saved_y + fullY;
|
||||
fieldDescriptor = partsData[i+1];
|
||||
fieldDescriptor |= partsData[i+2] << 8;
|
||||
if(x >= fullW || x < 0 || y >= fullH || y < 0)
|
||||
if (x >= fullW || y >= fullH)
|
||||
{
|
||||
fprintf(stderr, "Out of range [%d]: %d %d, [%d, %d], [%d, %d]\n", i, x, y, (unsigned)partsData[i+1], (unsigned)partsData[i+2], (unsigned)partsData[i+3], (unsigned)partsData[i+4]);
|
||||
goto fail;
|
||||
}
|
||||
if(partsData[i] >= PT_NUM)
|
||||
if (partsData[i] >= PT_NUM)
|
||||
partsData[i] = PT_DMND; //Replace all invalid elements with diamond
|
||||
|
||||
if(newIndex < 0 || newIndex >= NPART)
|
||||
if (newIndex < 0 || newIndex >= NPART)
|
||||
goto fail;
|
||||
|
||||
//Store partsptr index+1 for this saved particle index (0 means not loaded)
|
||||
@ -1038,13 +1037,13 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
}
|
||||
if (soapLinkData)
|
||||
{
|
||||
int soapLinkDataPos = 0;
|
||||
for (i=0; i<partsCount; i++)
|
||||
unsigned int soapLinkDataPos = 0;
|
||||
for (unsigned int i = 0; i < partsCount; i++)
|
||||
{
|
||||
if (partsSimIndex[i] && particles[partsSimIndex[i]-1].type == PT_SOAP)
|
||||
{
|
||||
// Get the index of the particle forward linked from this one, if present in the save data
|
||||
int linkedIndex = 0;
|
||||
unsigned int linkedIndex = 0;
|
||||
if (soapLinkDataPos+3 > soapLinkDataLen) break;
|
||||
linkedIndex |= soapLinkData[soapLinkDataPos++]<<16;
|
||||
linkedIndex |= soapLinkData[soapLinkDataPos++]<<8;
|
||||
@ -1067,7 +1066,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
||||
|
||||
if(tempSigns.size())
|
||||
{
|
||||
for (int i = 0; i < tempSigns.size(); i++)
|
||||
for (size_t i = 0; i < tempSigns.size(); i++)
|
||||
{
|
||||
if(signs.size() == MAXSIGNS)
|
||||
break;
|
||||
@ -1189,7 +1188,7 @@ void GameSave::readPSv(char * data, int dataLength)
|
||||
setSize(bw, bh);
|
||||
|
||||
int bzStatus = 0;
|
||||
if (bzStatus = BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), dataLength-12, 0, 0))
|
||||
if ((bzStatus = BZ2_bzBuffToBuffDecompress((char *)d, (unsigned *)&i, (char *)(c+12), dataLength-12, 0, 0)))
|
||||
{
|
||||
std::stringstream bzStatusStr;
|
||||
bzStatusStr << bzStatus;
|
||||
@ -1717,7 +1716,7 @@ void GameSave::readPSv(char * data, int dataLength)
|
||||
p += x;
|
||||
}
|
||||
|
||||
for (i = 0; i < tempSigns.size(); i++)
|
||||
for (size_t i = 0; i < tempSigns.size(); i++)
|
||||
{
|
||||
if(signs.size() == MAXSIGNS)
|
||||
break;
|
||||
@ -1763,7 +1762,7 @@ void GameSave::readPSv(char * data, int dataLength)
|
||||
}
|
||||
}
|
||||
|
||||
char * GameSave::serialiseOPS(int & dataLength)
|
||||
char * GameSave::serialiseOPS(unsigned int & dataLength)
|
||||
{
|
||||
//Particle *particles = sim->parts;
|
||||
unsigned char *partsData = NULL, *partsPosData = NULL, *fanData = NULL, *wallData = NULL, *finalData = NULL, *outputData = NULL, *soapLinkData = NULL;
|
||||
@ -2131,17 +2130,17 @@ char * GameSave::serialiseOPS(int & dataLength)
|
||||
bson_append_finish_array(&b);
|
||||
}
|
||||
signsCount = 0;
|
||||
for(i = 0; i < signs.size(); i++)
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
if(signs[i].text.length() && signs[i].x>=0 && signs[i].x<=fullW && signs[i].y>=0 && signs[i].y<=fullH)
|
||||
{
|
||||
signsCount++;
|
||||
}
|
||||
}
|
||||
if(signsCount)
|
||||
if (signsCount)
|
||||
{
|
||||
bson_append_start_array(&b, "signs");
|
||||
for(i = 0; i < signs.size(); i++)
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
if(signs[i].text.length() && signs[i].x>=0 && signs[i].x<=fullW && signs[i].y>=0 && signs[i].y<=fullH)
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
GameSave(std::vector<unsigned char> data);
|
||||
~GameSave();
|
||||
void setSize(int width, int height);
|
||||
char * Serialise(int & dataSize);
|
||||
char * Serialise(unsigned int & dataSize);
|
||||
std::vector<char> Serialise();
|
||||
void Transform(matrix2d transform, vector2d translate);
|
||||
|
||||
@ -100,7 +100,7 @@ private:
|
||||
void read(char * data, int dataSize);
|
||||
void readOPS(char * data, int dataLength);
|
||||
void readPSv(char * data, int dataLength);
|
||||
char * serialiseOPS(int & dataSize);
|
||||
char * serialiseOPS(unsigned int & dataSize);
|
||||
//serialisePSv();
|
||||
};
|
||||
|
||||
|
@ -906,7 +906,7 @@ const char *http_ret_text(int ret)
|
||||
return "Unknown Status Code";
|
||||
}
|
||||
}
|
||||
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id, int *ret, int *len)
|
||||
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, size_t *plens, const char *user, const char *pass, const char *session_id, int *ret, int *len)
|
||||
{
|
||||
void *ctx;
|
||||
char *data = NULL, *tmp;
|
||||
@ -925,7 +925,7 @@ char *http_multipart_post(const char *uri, const char *const *names, const char
|
||||
{
|
||||
own_plen = 1;
|
||||
for (i=0; names[i]; i++) ;
|
||||
plens = (int *)calloc(i, sizeof(int));
|
||||
plens = (size_t *)calloc(i, sizeof(size_t));
|
||||
for (i=0; names[i]; i++)
|
||||
plens[i] = strlen(parts[i]);
|
||||
}
|
||||
@ -936,7 +936,7 @@ retry:
|
||||
memset(map, 0, 62*sizeof(int));
|
||||
for (i=0; names[i]; i++)
|
||||
{
|
||||
for (j=0; j<plens[i]-blen; j++)
|
||||
for (unsigned int j=0; j<plens[i]-blen; j++)
|
||||
if (!blen || !memcmp(parts[i]+j, boundary, blen))
|
||||
{
|
||||
ch = parts[i][j+blen];
|
||||
|
@ -38,7 +38,7 @@ void http_async_get_length(void *ctx, int *total, int *done);
|
||||
char *http_async_req_stop(void *ctx, int *ret, int *len);
|
||||
void http_async_req_close(void *ctx);
|
||||
|
||||
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
|
||||
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, size_t *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
|
||||
void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id);
|
||||
|
||||
const char *http_ret_text(int ret);
|
||||
|
@ -109,7 +109,7 @@ void md5_final(unsigned char digest[16], struct md5_context *ctx)
|
||||
putu32(ctx->buf[1], digest + 4);
|
||||
putu32(ctx->buf[2], digest + 8);
|
||||
putu32(ctx->buf[3], digest + 12);
|
||||
memset(ctx, 0, sizeof(ctx));
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
}
|
||||
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include "gui/search/Thumbnail.h"
|
||||
|
||||
SaveFile::SaveFile(SaveFile & save):
|
||||
gameSave(NULL),
|
||||
thumbnail(NULL),
|
||||
gameSave(NULL),
|
||||
filename(save.filename),
|
||||
displayName(save.displayName)
|
||||
{
|
||||
@ -26,10 +26,10 @@ void SaveFile::SetThumbnail(Thumbnail * thumb)
|
||||
}
|
||||
|
||||
SaveFile::SaveFile(std::string filename):
|
||||
filename(filename),
|
||||
displayName(filename),
|
||||
gameSave(NULL),
|
||||
thumbnail(NULL)
|
||||
thumbnail(NULL),
|
||||
gameSave(NULL),
|
||||
filename(filename),
|
||||
displayName(filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -3,60 +3,64 @@
|
||||
#include "Client.h"
|
||||
|
||||
SaveInfo::SaveInfo(SaveInfo & save):
|
||||
userName(save.userName),
|
||||
name(save.name),
|
||||
Description(save.Description),
|
||||
date(save.date),
|
||||
Published(save.Published),
|
||||
id(save.id),
|
||||
votesUp(save.votesUp),
|
||||
votesDown(save.votesDown),
|
||||
gameSave(NULL),
|
||||
vote(save.vote),
|
||||
Comments(save.Comments),
|
||||
Views(save.Views),
|
||||
Version(save.Version)
|
||||
id(save.id),
|
||||
date(save.date),
|
||||
votesUp(save.votesUp),
|
||||
votesDown(save.votesDown),
|
||||
vote(save.vote),
|
||||
Favourite(false),
|
||||
Comments(save.Comments),
|
||||
Views(save.Views),
|
||||
Version(save.Version),
|
||||
userName(save.userName),
|
||||
name(save.name),
|
||||
Description(save.Description),
|
||||
Published(save.Published),
|
||||
gameSave(NULL)
|
||||
{
|
||||
std::list<std::string> tagsSorted = save.tags;
|
||||
tagsSorted.sort();
|
||||
tags=tagsSorted;
|
||||
if(save.gameSave)
|
||||
tags = tagsSorted;
|
||||
if (save.gameSave)
|
||||
gameSave = new GameSave(*save.gameSave);
|
||||
}
|
||||
|
||||
SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name):
|
||||
id(_id),
|
||||
votesUp(_votesUp),
|
||||
votesDown(_votesDown),
|
||||
userName(_userName),
|
||||
name(_name),
|
||||
Description(""),
|
||||
date(_date),
|
||||
Published(false),
|
||||
gameSave(NULL),
|
||||
vote(0),
|
||||
tags(),
|
||||
Comments(0),
|
||||
Views(0),
|
||||
Version(0)
|
||||
id(_id),
|
||||
date(_date),
|
||||
votesUp(_votesUp),
|
||||
votesDown(_votesDown),
|
||||
vote(0),
|
||||
Favourite(false),
|
||||
Comments(0),
|
||||
Views(0),
|
||||
Version(0),
|
||||
userName(_userName),
|
||||
name(_name),
|
||||
Description(""),
|
||||
Published(false),
|
||||
tags(),
|
||||
gameSave(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags_):
|
||||
id(_id),
|
||||
votesUp(_votesUp),
|
||||
votesDown(_votesDown),
|
||||
userName(_userName),
|
||||
name(_name),
|
||||
Description(description_),
|
||||
date(date_),
|
||||
Published(published_),
|
||||
gameSave(NULL),
|
||||
vote(_vote),
|
||||
Comments(0),
|
||||
Views(0),
|
||||
Version(0)
|
||||
id(_id),
|
||||
date(date_),
|
||||
votesUp(_votesUp),
|
||||
votesDown(_votesDown),
|
||||
vote(_vote),
|
||||
Favourite(false),
|
||||
Comments(0),
|
||||
Views(0),
|
||||
Version(0),
|
||||
userName(_userName),
|
||||
name(_name),
|
||||
Description(description_),
|
||||
Published(published_),
|
||||
tags(),
|
||||
gameSave(NULL)
|
||||
{
|
||||
std::list<std::string> tagsSorted = tags_;
|
||||
tagsSorted.sort();
|
||||
|
@ -16,11 +16,19 @@ public:
|
||||
int id;
|
||||
int date;
|
||||
int votesUp, votesDown;
|
||||
int vote;
|
||||
bool Favourite;
|
||||
int Comments;
|
||||
int Views;
|
||||
int Version;
|
||||
|
||||
std::string userName;
|
||||
|
||||
std::string name;
|
||||
std::string Description;
|
||||
bool Published;
|
||||
|
||||
std::list<std::string> tags;
|
||||
GameSave * gameSave;
|
||||
|
||||
SaveInfo(SaveInfo & save);
|
||||
@ -31,17 +39,6 @@ public:
|
||||
|
||||
~SaveInfo();
|
||||
|
||||
std::string userName;
|
||||
std::string name;
|
||||
|
||||
std::string Description;
|
||||
|
||||
std::list<std::string> tags;
|
||||
|
||||
int vote;
|
||||
|
||||
bool Published;
|
||||
|
||||
void SetName(std::string name);
|
||||
std::string GetName();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define PIXG(x) (((x)>>16)&0xFF)
|
||||
#define PIXB(x) (((x)>>24)&0xFF)
|
||||
#elif defined(PIX32OGL)
|
||||
#undef PIXELCHANNELS
|
||||
#define PIXELCHANNELS 4
|
||||
#define PIXPACK(x) (0xFF000000|((x)&0xFFFFFF)) //32bit ARGB in 32bit int: AARRGGBB
|
||||
#define PIXRGB(r,g,b) (0xFF000000|((r)<<16)|((g)<<8)|((b)))
|
||||
|
@ -135,9 +135,8 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, std::string s, int r, int g, int
|
||||
|
||||
int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a)
|
||||
{
|
||||
int i, j, w, bn = 0, ba = 0;
|
||||
unsigned char *rp = font_data + font_ptrs[c];
|
||||
w = *(rp++);
|
||||
int w = *(rp++);
|
||||
VideoBuffer texture(w, 12);
|
||||
texture.SetCharacter(0, 0, c, r, g, b, a);
|
||||
|
||||
@ -165,9 +164,8 @@ int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a
|
||||
|
||||
int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
|
||||
{
|
||||
int i, j, w, bn = 0, ba = 0;
|
||||
unsigned char *rp = font_data + font_ptrs[c];
|
||||
w = *(rp++);
|
||||
int w = *(rp++);
|
||||
VideoBuffer texture(w, 12);
|
||||
texture.AddCharacter(0, 0, c, r, g, b, a);
|
||||
|
||||
|
@ -912,7 +912,7 @@ void Renderer::DrawWalls()
|
||||
|
||||
void Renderer::DrawSigns()
|
||||
{
|
||||
int i, j, x, y, w, h, dx, dy;
|
||||
int x, y, w, h;
|
||||
std::vector<sign> signs = sim->signs;
|
||||
#ifdef OGLR
|
||||
GLint prevFbo;
|
||||
@ -920,7 +920,7 @@ void Renderer::DrawSigns()
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||
glTranslated(0, MENUSIZE, 0);
|
||||
#endif
|
||||
for (i=0; i < signs.size(); i++)
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
if (signs[i].text.length())
|
||||
{
|
||||
char type = 0;
|
||||
@ -936,10 +936,10 @@ void Renderer::DrawSigns()
|
||||
else
|
||||
drawtext(x+3, y+3, text, 0, 191, 255, 255);
|
||||
|
||||
x = signs[i].x;
|
||||
y = signs[i].y;
|
||||
dx = 1 - signs[i].ju;
|
||||
dy = (signs[i].y > 18) ? -1 : 1;
|
||||
int x = signs[i].x;
|
||||
int y = signs[i].y;
|
||||
int dx = 1 - signs[i].ju;
|
||||
int dy = (signs[i].y > 18) ? -1 : 1;
|
||||
#ifdef OGLR
|
||||
glBegin(GL_LINES);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
@ -947,11 +947,11 @@ void Renderer::DrawSigns()
|
||||
glVertex2i(x+(dx*4), y+(dy*4));
|
||||
glEnd();
|
||||
#else
|
||||
for (j=0; j<4; j++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
blendpixel(x, y, 192, 192, 192, 255);
|
||||
x+=dx;
|
||||
y+=dy;
|
||||
x += dx;
|
||||
y += dy;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -2424,22 +2424,22 @@ pixel Renderer::GetPixel(int x, int y)
|
||||
Renderer::Renderer(Graphics * g, Simulation * sim):
|
||||
sim(NULL),
|
||||
g(NULL),
|
||||
render_mode(0),
|
||||
colour_mode(0),
|
||||
display_mode(0),
|
||||
gravityZonesEnabled(false),
|
||||
gravityFieldEnabled(false),
|
||||
decorations_enable(1),
|
||||
blackDecorations(false),
|
||||
debugLines(false),
|
||||
sampleColor(0xFFFFFFFF),
|
||||
mousePos(0, 0),
|
||||
zoomWindowPosition(0, 0),
|
||||
zoomScopePosition(0, 0),
|
||||
zoomScopeSize(32),
|
||||
ZFACTOR(8),
|
||||
zoomEnabled(false),
|
||||
decorations_enable(1),
|
||||
gravityFieldEnabled(false),
|
||||
gravityZonesEnabled(false),
|
||||
mousePos(0, 0),
|
||||
display_mode(0),
|
||||
render_mode(0),
|
||||
colour_mode(0),
|
||||
gridSize(0),
|
||||
blackDecorations(false),
|
||||
debugLines(false),
|
||||
sampleColor(0xFFFFFFFF)
|
||||
ZFACTOR(8),
|
||||
gridSize(0)
|
||||
{
|
||||
this->g = g;
|
||||
this->sim = sim;
|
||||
@ -2688,7 +2688,7 @@ void Renderer::CompileRenderMode()
|
||||
{
|
||||
int old_render_mode = render_mode;
|
||||
render_mode = 0;
|
||||
for(int i = 0; i < render_modes.size(); i++)
|
||||
for (size_t i = 0; i < render_modes.size(); i++)
|
||||
render_mode |= render_modes[i];
|
||||
|
||||
//If firemode is removed, clear the fire display
|
||||
@ -2710,7 +2710,7 @@ void Renderer::ClearAccumulation()
|
||||
|
||||
void Renderer::AddRenderMode(unsigned int mode)
|
||||
{
|
||||
for(int i = 0; i < render_modes.size(); i++)
|
||||
for (size_t i = 0; i < render_modes.size(); i++)
|
||||
{
|
||||
if(render_modes[i] == mode)
|
||||
{
|
||||
@ -2723,7 +2723,7 @@ void Renderer::AddRenderMode(unsigned int mode)
|
||||
|
||||
void Renderer::RemoveRenderMode(unsigned int mode)
|
||||
{
|
||||
for(int i = 0; i < render_modes.size(); i++)
|
||||
for (size_t i = 0; i < render_modes.size(); i++)
|
||||
{
|
||||
if(render_modes[i] == mode)
|
||||
{
|
||||
@ -2749,9 +2749,9 @@ void Renderer::CompileDisplayMode()
|
||||
{
|
||||
int old_display_mode = display_mode;
|
||||
display_mode = 0;
|
||||
for(int i = 0; i < display_modes.size(); i++)
|
||||
for (size_t i = 0; i < display_modes.size(); i++)
|
||||
display_mode |= display_modes[i];
|
||||
if(!(display_mode & DISPLAY_PERS) && (old_display_mode & DISPLAY_PERS))
|
||||
if (!(display_mode & DISPLAY_PERS) && (old_display_mode & DISPLAY_PERS))
|
||||
{
|
||||
ClearAccumulation();
|
||||
}
|
||||
@ -2759,13 +2759,13 @@ void Renderer::CompileDisplayMode()
|
||||
|
||||
void Renderer::AddDisplayMode(unsigned int mode)
|
||||
{
|
||||
for(int i = 0; i < display_modes.size(); i++)
|
||||
for (size_t i = 0; i < display_modes.size(); i++)
|
||||
{
|
||||
if(display_modes[i] == mode)
|
||||
if (display_modes[i] == mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(display_modes[i] & DISPLAY_AIR)
|
||||
if (display_modes[i] & DISPLAY_AIR)
|
||||
{
|
||||
display_modes.erase(display_modes.begin()+i);
|
||||
}
|
||||
@ -2776,9 +2776,9 @@ void Renderer::AddDisplayMode(unsigned int mode)
|
||||
|
||||
void Renderer::RemoveDisplayMode(unsigned int mode)
|
||||
{
|
||||
for(int i = 0; i < display_modes.size(); i++)
|
||||
for (size_t i = 0; i < display_modes.size(); i++)
|
||||
{
|
||||
if(display_modes[i] == mode)
|
||||
if (display_modes[i] == mode)
|
||||
{
|
||||
display_modes.erase(display_modes.begin() + i);
|
||||
i = 0;
|
||||
|
@ -41,6 +41,10 @@ typedef struct gcache_item gcache_item;
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
Simulation * sim;
|
||||
Graphics * g;
|
||||
gcache_item *graphicscache;
|
||||
|
||||
std::vector<unsigned int> render_modes;
|
||||
unsigned int render_mode;
|
||||
unsigned int colour_mode;
|
||||
@ -60,9 +64,6 @@ public:
|
||||
int decorations_enable;
|
||||
bool blackDecorations;
|
||||
bool debugLines;
|
||||
Simulation * sim;
|
||||
Graphics * g;
|
||||
gcache_item *graphicscache;
|
||||
pixel sampleColor;
|
||||
|
||||
//Mouse position for debug information
|
||||
|
@ -58,7 +58,7 @@ private:
|
||||
notifyStatus("Unpacking update");
|
||||
notifyProgress(-1);
|
||||
|
||||
int uncompressedLength;
|
||||
unsigned int uncompressedLength;
|
||||
|
||||
if(dataLength<16)
|
||||
{
|
||||
|
@ -52,6 +52,8 @@ int luacon_partread(lua_State* l)
|
||||
tempfloat = *((float*)(((unsigned char*)&luacon_sim->parts[i])+offset));
|
||||
lua_pushnumber(l, tempfloat);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -78,6 +80,8 @@ int luacon_partwrite(lua_State* l)
|
||||
break;
|
||||
case CommandInterface::FormatElement:
|
||||
luacon_sim->part_change_type(i, luacon_sim->parts[i].x, luacon_sim->parts[i].y, luaL_optinteger(l, 3, 0));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -403,9 +407,8 @@ int luacon_elementwrite(lua_State* l)
|
||||
tempstring = mystrdup((char*)luaL_optstring(l, 3, ""));
|
||||
if (!strcmp(key, "name"))
|
||||
{
|
||||
int j = 0;
|
||||
//Convert to upper case
|
||||
for(j = 0; j < strlen(tempstring); j++)
|
||||
for (size_t j = 0; j < strlen(tempstring); j++)
|
||||
tempstring[j] = toupper(tempstring[j]);
|
||||
if(luacon_ci->GetParticleType(tempstring) != -1)
|
||||
{
|
||||
@ -1051,15 +1054,14 @@ int luatpt_reset_spark(lua_State* l)
|
||||
|
||||
int luatpt_set_property(lua_State* l)
|
||||
{
|
||||
const char *prop, *name;
|
||||
int r, i, x, y, w, h, t, nx, ny, partsel = 0, acount;
|
||||
const char *name;
|
||||
int r, i, x, y, w, h, t, nx, ny, partsel = 0;
|
||||
float f;
|
||||
size_t offset;
|
||||
acount = lua_gettop(l);
|
||||
prop = luaL_optstring(l, 1, "");
|
||||
int acount = lua_gettop(l);
|
||||
const char* prop = luaL_optstring(l, 1, "");
|
||||
|
||||
CommandInterface::FormatType format;
|
||||
offset = luacon_ci->GetPropertyOffset(prop, format);
|
||||
int offset = luacon_ci->GetPropertyOffset(prop, format);
|
||||
if (offset == -1)
|
||||
return luaL_error(l, "Invalid property '%s'", prop);
|
||||
|
||||
@ -1316,14 +1318,17 @@ int luatpt_get_property(lua_State* l)
|
||||
}
|
||||
switch(format)
|
||||
{
|
||||
case CommandInterface::FormatInt:
|
||||
case CommandInterface::FormatElement:
|
||||
tempinteger = *((int*)(((unsigned char*)&luacon_sim->parts[i])+offset));
|
||||
lua_pushnumber(l, tempinteger);
|
||||
break;
|
||||
case CommandInterface::FormatFloat:
|
||||
tempfloat = *((float*)(((unsigned char*)&luacon_sim->parts[i])+offset));
|
||||
lua_pushnumber(l, tempfloat);
|
||||
case CommandInterface::FormatInt:
|
||||
case CommandInterface::FormatElement:
|
||||
tempinteger = *((int*)(((unsigned char*)&luacon_sim->parts[i])+offset));
|
||||
lua_pushnumber(l, tempinteger);
|
||||
break;
|
||||
case CommandInterface::FormatFloat:
|
||||
tempfloat = *((float*)(((unsigned char*)&luacon_sim->parts[i])+offset));
|
||||
lua_pushnumber(l, tempfloat);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -88,8 +88,6 @@ int TptNewindexClosure(lua_State *l)
|
||||
|
||||
LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
CommandInterface(c, m),
|
||||
currentCommand(false),
|
||||
legacy(new TPTScriptInterface(c, m)),
|
||||
luacon_mousex(0),
|
||||
luacon_mousey(0),
|
||||
luacon_mousebutton(0),
|
||||
@ -99,7 +97,9 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
luacon_selectedr(""),
|
||||
luacon_selectedalt(""),
|
||||
luacon_selectedreplace(""),
|
||||
luacon_mousedown(false)
|
||||
luacon_mousedown(false),
|
||||
currentCommand(false),
|
||||
legacy(new TPTScriptInterface(c, m))
|
||||
{
|
||||
luacon_model = m;
|
||||
luacon_controller = c;
|
||||
@ -137,7 +137,6 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
initFileSystemAPI();
|
||||
|
||||
//Old TPT API
|
||||
int i = 0, j;
|
||||
char tmpname[12];
|
||||
int currentElementMeta, currentElement;
|
||||
const static struct luaL_Reg tptluaapi [] = {
|
||||
@ -281,9 +280,9 @@ tpt.partsdata = nil");
|
||||
|
||||
lua_newtable(l);
|
||||
tptElements = lua_gettop(l);
|
||||
for(i = 1; i < PT_NUM; i++)
|
||||
for (int i = 1; i < PT_NUM; i++)
|
||||
{
|
||||
for(j = 0; j < strlen(luacon_sim->elements[i].Name); j++)
|
||||
for (size_t j = 0; j < strlen(luacon_sim->elements[i].Name); j++)
|
||||
tmpname[j] = tolower(luacon_sim->elements[i].Name[j]);
|
||||
tmpname[strlen(luacon_sim->elements[i].Name)] = 0;
|
||||
|
||||
@ -306,9 +305,9 @@ tpt.partsdata = nil");
|
||||
|
||||
lua_newtable(l);
|
||||
tptElementTransitions = lua_gettop(l);
|
||||
for(i = 1; i < PT_NUM; i++)
|
||||
for (int i = 1; i < PT_NUM; i++)
|
||||
{
|
||||
for(j = 0; j < strlen(luacon_sim->elements[i].Name); j++)
|
||||
for (size_t j = 0; j < strlen(luacon_sim->elements[i].Name); j++)
|
||||
tmpname[j] = tolower(luacon_sim->elements[i].Name[j]);
|
||||
tmpname[strlen(luacon_sim->elements[i].Name)] = 0;
|
||||
|
||||
@ -331,7 +330,7 @@ tpt.partsdata = nil");
|
||||
lua_el_func = (int*)calloc(PT_NUM, sizeof(int));
|
||||
lua_el_mode = (int*)calloc(PT_NUM, sizeof(int));
|
||||
lua_gr_func = (int*)calloc(PT_NUM, sizeof(int));
|
||||
for(i = 0; i < PT_NUM; i++)
|
||||
for (int i = 0; i < PT_NUM; i++)
|
||||
{
|
||||
lua_el_mode[i] = 0;
|
||||
lua_gr_func[i] = 0;
|
||||
@ -470,21 +469,21 @@ int LuaScriptInterface::interface_addComponent(lua_State * l)
|
||||
{
|
||||
void * luaComponent = NULL;
|
||||
ui::Component * component = NULL;
|
||||
if(luaComponent = Luna<LuaButton>::tryGet(l, 1))
|
||||
if ((luaComponent = Luna<LuaButton>::tryGet(l, 1)))
|
||||
component = Luna<LuaButton>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaLabel>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaLabel>::tryGet(l, 1)))
|
||||
component = Luna<LuaLabel>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaTextbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaTextbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaTextbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaCheckbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaCheckbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaCheckbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaSlider>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaSlider>::tryGet(l, 1)))
|
||||
component = Luna<LuaSlider>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaProgressBar>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaProgressBar>::tryGet(l, 1)))
|
||||
component = Luna<LuaProgressBar>::get(luaComponent)->GetComponent();
|
||||
else
|
||||
luaL_typerror(l, 1, "Component");
|
||||
if(luacon_ci->Window && component)
|
||||
if (luacon_ci->Window && component)
|
||||
luacon_ci->Window->AddComponent(component);
|
||||
return 0;
|
||||
}
|
||||
@ -493,17 +492,17 @@ int LuaScriptInterface::interface_removeComponent(lua_State * l)
|
||||
{
|
||||
void * luaComponent = NULL;
|
||||
ui::Component * component = NULL;
|
||||
if(luaComponent = Luna<LuaButton>::tryGet(l, 1))
|
||||
if ((luaComponent = Luna<LuaButton>::tryGet(l, 1)))
|
||||
component = Luna<LuaButton>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaLabel>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaLabel>::tryGet(l, 1)))
|
||||
component = Luna<LuaLabel>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaTextbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaTextbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaTextbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaCheckbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaCheckbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaCheckbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaSlider>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaSlider>::tryGet(l, 1)))
|
||||
component = Luna<LuaSlider>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaProgressBar>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaProgressBar>::tryGet(l, 1)))
|
||||
component = Luna<LuaProgressBar>::get(luaComponent)->GetComponent();
|
||||
else
|
||||
luaL_typerror(l, 1, "Component");
|
||||
@ -1097,7 +1096,7 @@ int LuaScriptInterface::simulation_createParts(lua_State * l)
|
||||
int flags = luaL_optint(l,7,luacon_sim->replaceModeFlags);
|
||||
|
||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||
if (brush < 0 || brush >= brushList.size())
|
||||
if (brush < 0 || brush >= (int)brushList.size())
|
||||
return luaL_error(l, "Invalid brush id '%d'", brush);
|
||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||
@ -1121,7 +1120,7 @@ int LuaScriptInterface::simulation_createLine(lua_State * l)
|
||||
int flags = luaL_optint(l,9,luacon_sim->replaceModeFlags);
|
||||
|
||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||
if (brush < 0 || brush >= brushList.size())
|
||||
if (brush < 0 || brush >= (int)brushList.size())
|
||||
return luaL_error(l, "Invalid brush id '%d'", brush);
|
||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||
@ -1223,16 +1222,16 @@ int LuaScriptInterface::simulation_toolBrush(lua_State * l)
|
||||
int tool = luaL_optint(l,5,0);
|
||||
int brush = luaL_optint(l,6,CIRCLE_BRUSH);
|
||||
float strength = luaL_optnumber(l,7,1.0f);
|
||||
if (tool == luacon_sim->tools.size())
|
||||
if (tool == (int)luacon_sim->tools.size())
|
||||
{
|
||||
lua_pushinteger(l, 0);
|
||||
return 1;
|
||||
}
|
||||
else if (tool < 0 || tool >= luacon_sim->tools.size())
|
||||
else if (tool < 0 || tool > (int)luacon_sim->tools.size())
|
||||
return luaL_error(l, "Invalid tool id '%d'", tool);
|
||||
|
||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||
if (brush < 0 || brush >= brushList.size())
|
||||
if (brush < 0 || brush >= (int)brushList.size())
|
||||
return luaL_error(l, "Invalid brush id '%d'", brush);
|
||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||
@ -1254,16 +1253,16 @@ int LuaScriptInterface::simulation_toolLine(lua_State * l)
|
||||
int tool = luaL_optint(l,7,0);
|
||||
int brush = luaL_optint(l,8,CIRCLE_BRUSH);
|
||||
float strength = luaL_optnumber(l,9,1.0f);
|
||||
if (tool < 0 || tool >= luacon_sim->tools.size()+1)
|
||||
if (tool < 0 || tool >= (int)luacon_sim->tools.size()+1)
|
||||
return luaL_error(l, "Invalid tool id '%d'", tool);
|
||||
|
||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||
if (brush < 0 || brush >= brushList.size())
|
||||
if (brush < 0 || brush >= (int)brushList.size())
|
||||
return luaL_error(l, "Invalid brush id '%d'", brush);
|
||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||
|
||||
if (tool == luacon_sim->tools.size())
|
||||
if (tool == (int)luacon_sim->tools.size())
|
||||
{
|
||||
Tool *WindTool = luacon_model->GetToolFromIdentifier("DEFAULT_UI_WIND");
|
||||
WindTool->DrawLine(luacon_sim, brushList[brush], ui::Point(x1, y1), ui::Point(x2, y2));
|
||||
@ -1283,12 +1282,12 @@ int LuaScriptInterface::simulation_toolBox(lua_State * l)
|
||||
int y2 = luaL_optint(l,4,-1);
|
||||
int tool = luaL_optint(l,5,0);
|
||||
float strength = luaL_optnumber(l,6,1.0f);
|
||||
if (tool == luacon_sim->tools.size())
|
||||
if (tool == (int)luacon_sim->tools.size())
|
||||
{
|
||||
lua_pushinteger(l, 0);
|
||||
return 1;
|
||||
}
|
||||
else if (tool < 0 || tool >= luacon_sim->tools.size())
|
||||
else if (tool < 0 || tool >= (int)luacon_sim->tools.size())
|
||||
return luaL_error(l, "Invalid tool id '%d'", tool);
|
||||
|
||||
luacon_sim->ToolBox(x1, y1, x2, y2, tool, strength);
|
||||
@ -1309,7 +1308,7 @@ int LuaScriptInterface::simulation_decoBrush(lua_State * l)
|
||||
int brush = luaL_optint(l,10,CIRCLE_BRUSH);
|
||||
|
||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||
if (brush < 0 || brush >= brushList.size())
|
||||
if (brush < 0 || brush >= (int)brushList.size())
|
||||
return luaL_error(l, "Invalid brush id '%d'", brush);
|
||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||
@ -1335,7 +1334,7 @@ int LuaScriptInterface::simulation_decoLine(lua_State * l)
|
||||
int brush = luaL_optint(l,12,CIRCLE_BRUSH);
|
||||
|
||||
vector<Brush*> brushList = luacon_model->GetBrushList();
|
||||
if (brush < 0 || brush >= brushList.size())
|
||||
if (brush < 0 || brush >= (int)brushList.size())
|
||||
return luaL_error(l, "Invalid brush id '%d'", brush);
|
||||
ui::Point tempRadius = brushList[brush]->GetRadius();
|
||||
brushList[brush]->SetRadius(ui::Point(rx, ry));
|
||||
@ -2071,11 +2070,11 @@ void LuaScriptInterface::initElementsAPI()
|
||||
int LuaScriptInterface::elements_loadDefault(lua_State * l)
|
||||
{
|
||||
int args = lua_gettop(l);
|
||||
if(args)
|
||||
if (args)
|
||||
{
|
||||
luaL_checktype(l, 1, LUA_TNUMBER);
|
||||
int id = lua_tointeger(l, 1);
|
||||
if(id < 0 || id >= PT_NUM)
|
||||
if (id < 0 || id >= PT_NUM)
|
||||
return luaL_error(l, "Invalid element");
|
||||
|
||||
lua_getglobal(l, "elements");
|
||||
@ -2083,7 +2082,7 @@ int LuaScriptInterface::elements_loadDefault(lua_State * l)
|
||||
lua_setfield(l, -2, luacon_sim->elements[id].Identifier);
|
||||
|
||||
std::vector<Element> elementList = GetElements();
|
||||
if(id < elementList.size())
|
||||
if (id < (int)elementList.size())
|
||||
luacon_sim->elements[id] = elementList[id];
|
||||
else
|
||||
luacon_sim->elements[id] = Element();
|
||||
@ -2095,9 +2094,9 @@ int LuaScriptInterface::elements_loadDefault(lua_State * l)
|
||||
else
|
||||
{
|
||||
std::vector<Element> elementList = GetElements();
|
||||
for(int i = 0; i < PT_NUM; i++)
|
||||
for (int i = 0; i < PT_NUM; i++)
|
||||
{
|
||||
if(i < elementList.size())
|
||||
if (i < (int)elementList.size())
|
||||
luacon_sim->elements[i] = elementList[i];
|
||||
else
|
||||
luacon_sim->elements[i] = Element();
|
||||
@ -2746,7 +2745,7 @@ int LuaScriptInterface::fileSystem_list(lua_State * l)
|
||||
directory = opendir(directoryName);
|
||||
if (directory != NULL)
|
||||
{
|
||||
while (entry = readdir(directory))
|
||||
while ((entry = readdir(directory)))
|
||||
{
|
||||
if(strncmp(entry->d_name, "..", 3) && strncmp(entry->d_name, ".", 2))
|
||||
{
|
||||
@ -3024,7 +3023,7 @@ void LuaScriptInterface::OnTick()
|
||||
|
||||
int LuaScriptInterface::Command(std::string command)
|
||||
{
|
||||
if(command[0] == '!')
|
||||
if (command[0] == '!')
|
||||
{
|
||||
lastError = "";
|
||||
int ret = legacy->Command(command.substr(1));
|
||||
@ -3037,21 +3036,22 @@ int LuaScriptInterface::Command(std::string command)
|
||||
std::string text = "";
|
||||
lastError = "";
|
||||
currentCommand = true;
|
||||
if(lastCode.length())
|
||||
if (lastCode.length())
|
||||
lastCode += "\n";
|
||||
lastCode += command;
|
||||
std::string tmp = "return " + lastCode;
|
||||
ui::Engine::Ref().LastTick(gettime());
|
||||
luaL_loadbuffer(l, tmp.c_str(), tmp.length(), "@console");
|
||||
if(lua_type(l, -1) != LUA_TFUNCTION)
|
||||
if (lua_type(l, -1) != LUA_TFUNCTION)
|
||||
{
|
||||
lua_pop(l, 1);
|
||||
luaL_loadbuffer(l, lastCode.c_str(), lastCode.length(), "@console");
|
||||
}
|
||||
if(lua_type(l, -1) != LUA_TFUNCTION)
|
||||
if (lua_type(l, -1) != LUA_TFUNCTION)
|
||||
{
|
||||
lastError = luacon_geterror();
|
||||
if(std::string(lastError).find("near '<eof>'")!=-1) //the idea stolen from lua-5.1.5/lua.c
|
||||
std::string err = lastError;
|
||||
if (err.find("near '<eof>'") != err.npos) //the idea stolen from lua-5.1.5/lua.c
|
||||
lastError = "...";
|
||||
else
|
||||
lastCode = "";
|
||||
@ -3060,24 +3060,26 @@ int LuaScriptInterface::Command(std::string command)
|
||||
{
|
||||
lastCode = "";
|
||||
ret = lua_pcall(l, 0, LUA_MULTRET, 0);
|
||||
if(ret)
|
||||
if (ret)
|
||||
lastError = luacon_geterror();
|
||||
else
|
||||
{
|
||||
for(level++;level<=lua_gettop(l);level++)
|
||||
for (level++;level<=lua_gettop(l);level++)
|
||||
{
|
||||
luaL_tostring(l, level);
|
||||
if(text.length())
|
||||
if (text.length())
|
||||
text += ", " + std::string(luaL_optstring(l, -1, ""));
|
||||
else
|
||||
text = std::string(luaL_optstring(l, -1, ""));
|
||||
lua_pop(l, 1);
|
||||
}
|
||||
if(text.length())
|
||||
if(lastError.length())
|
||||
if (text.length())
|
||||
{
|
||||
if (lastError.length())
|
||||
lastError += "; " + text;
|
||||
else
|
||||
lastError = text;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -3112,7 +3114,7 @@ std::string highlight(std::string command)
|
||||
int pos = 0;
|
||||
const char *raw = command.c_str();
|
||||
char c;
|
||||
while(c = raw[pos])
|
||||
while ((c = raw[pos]))
|
||||
{
|
||||
if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_')
|
||||
{
|
||||
@ -3164,10 +3166,12 @@ std::string highlight(std::string command)
|
||||
while((w = wstart[len]) && ((w >= '0' && w <= '9') || w == '.'))
|
||||
{
|
||||
if(w == '.')
|
||||
{
|
||||
if(seendot)
|
||||
break;
|
||||
else
|
||||
seendot = true;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
if(w == 'e')
|
||||
|
@ -109,17 +109,17 @@ int LuaWindow::addComponent(lua_State * l)
|
||||
{
|
||||
void * luaComponent = NULL;
|
||||
ui::Component * component = NULL;
|
||||
if(luaComponent = Luna<LuaButton>::tryGet(l, 1))
|
||||
if ((luaComponent = Luna<LuaButton>::tryGet(l, 1)))
|
||||
component = Luna<LuaButton>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaLabel>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaLabel>::tryGet(l, 1)))
|
||||
component = Luna<LuaLabel>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaTextbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaTextbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaTextbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaCheckbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaCheckbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaCheckbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaSlider>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaSlider>::tryGet(l, 1)))
|
||||
component = Luna<LuaSlider>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaProgressBar>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaProgressBar>::tryGet(l, 1)))
|
||||
component = Luna<LuaProgressBar>::get(luaComponent)->GetComponent();
|
||||
else
|
||||
luaL_typerror(l, 1, "Component");
|
||||
@ -132,17 +132,17 @@ int LuaWindow::removeComponent(lua_State * l)
|
||||
{
|
||||
void * luaComponent = NULL;
|
||||
ui::Component * component = NULL;
|
||||
if(luaComponent = Luna<LuaButton>::tryGet(l, 1))
|
||||
if ((luaComponent = Luna<LuaButton>::tryGet(l, 1)))
|
||||
component = Luna<LuaButton>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaLabel>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaLabel>::tryGet(l, 1)))
|
||||
component = Luna<LuaLabel>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaTextbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaTextbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaTextbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaCheckbox>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaCheckbox>::tryGet(l, 1)))
|
||||
component = Luna<LuaCheckbox>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaSlider>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaSlider>::tryGet(l, 1)))
|
||||
component = Luna<LuaSlider>::get(luaComponent)->GetComponent();
|
||||
else if(luaComponent = Luna<LuaProgressBar>::tryGet(l, 1))
|
||||
else if ((luaComponent = Luna<LuaProgressBar>::tryGet(l, 1)))
|
||||
component = Luna<LuaProgressBar>::get(luaComponent)->GetComponent();
|
||||
else
|
||||
luaL_typerror(l, 1, "Component");
|
||||
|
@ -61,27 +61,27 @@ int TPTScriptInterface::Command(std::string command)
|
||||
|
||||
ValueType TPTScriptInterface::testType(std::string word)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
char * rawWord = (char *)word.c_str();
|
||||
//Function
|
||||
if(word == "set")
|
||||
if (word == "set")
|
||||
return TypeFunction;
|
||||
else if(word == "create")
|
||||
else if (word == "create")
|
||||
return TypeFunction;
|
||||
else if(word == "delete")
|
||||
else if (word == "delete")
|
||||
return TypeFunction;
|
||||
else if(word == "kill")
|
||||
else if (word == "kill")
|
||||
return TypeFunction;
|
||||
else if(word == "load")
|
||||
else if (word == "load")
|
||||
return TypeFunction;
|
||||
else if(word == "reset")
|
||||
else if (word == "reset")
|
||||
return TypeFunction;
|
||||
else if(word == "bubble")
|
||||
else if (word == "bubble")
|
||||
return TypeFunction;
|
||||
else if(word == "quit")
|
||||
else if (word == "quit")
|
||||
return TypeFunction;
|
||||
//Basic type
|
||||
for(i = 0; i < word.length(); i++)
|
||||
for (i = 0; i < word.length(); i++)
|
||||
{
|
||||
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))
|
||||
{
|
||||
@ -101,21 +101,21 @@ ValueType TPTScriptInterface::testType(std::string word)
|
||||
return TypeNumber;
|
||||
parseFloat:
|
||||
for (i++; i < word.length(); i++)
|
||||
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||
if (!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||
{
|
||||
goto parseString;
|
||||
}
|
||||
return TypeFloat;
|
||||
parseNumberHex:
|
||||
for (i++; i < word.length(); i++)
|
||||
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||
if (!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
|
||||
{
|
||||
goto parseString;
|
||||
}
|
||||
return TypeNumber;
|
||||
parsePoint:
|
||||
for (i++; i < word.length(); i++)
|
||||
if(!(rawWord[i] >= '0' && rawWord[i] <= '9'))
|
||||
if (!(rawWord[i] >= '0' && rawWord[i] <= '9'))
|
||||
{
|
||||
goto parseString;
|
||||
}
|
||||
@ -141,14 +141,14 @@ float TPTScriptInterface::parseNumber(char * stringData)
|
||||
}
|
||||
if (base == 16)
|
||||
{
|
||||
while(cc = *(stringData++))
|
||||
while ((cc = *(stringData++)))
|
||||
{
|
||||
currentNumber *= base;
|
||||
if(cc >= '0' && cc <= '9')
|
||||
if (cc >= '0' && cc <= '9')
|
||||
currentNumber += cc - '0';
|
||||
else if(cc >= 'a' && cc <= 'f')
|
||||
else if (cc >= 'a' && cc <= 'f')
|
||||
currentNumber += (cc - 'a') + 10;
|
||||
else if(cc >= 'A' && cc <= 'F')
|
||||
else if (cc >= 'A' && cc <= 'F')
|
||||
currentNumber += (cc - 'A') + 10;
|
||||
else
|
||||
break;
|
||||
@ -198,6 +198,8 @@ AnyType TPTScriptInterface::eval(std::deque<std::string> * words)
|
||||
}
|
||||
case TypeString:
|
||||
return StringType(word);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return StringType(word);
|
||||
}
|
||||
@ -330,6 +332,8 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
case FormatElement:
|
||||
sim->part_change_type(partIndex, sim->parts[partIndex].x, sim->parts[partIndex].y, newValue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
returnValue = 1;
|
||||
}
|
||||
@ -366,7 +370,9 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
sim->part_change_type(j, sim->parts[j].x, sim->parts[j].y, newValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(selector.GetType() == TypeString || selector.GetType() == TypeNumber)
|
||||
@ -413,6 +419,9 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
|
||||
sim->part_change_type(j, sim->parts[j].x, sim->parts[j].y, newValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -76,11 +76,11 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
|
||||
size_t size = 0, sent = 0;
|
||||
const char *data = luaL_checklstring(L, 2, &size);
|
||||
long start = (long) luaL_optnumber(L, 3, 1);
|
||||
long end = (long) luaL_optnumber(L, 4, -1);
|
||||
long end = (long) luaL_optnumber(L, 4, -1);
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
p_timeout tm = timeout_markstart(buf->tm);
|
||||
p_timeout tm = timeout_markstart(buf->tm);
|
||||
#else
|
||||
timeout_markstart(buf->tm); //not sure if this is needed, but prevent warning anyway
|
||||
timeout_markstart(buf->tm); //not sure if this is needed, but prevent warning anyway
|
||||
#endif
|
||||
if (start < 0) start = (long) (size+start+1);
|
||||
if (end < 0) end = (long) (size+end+1);
|
||||
@ -115,7 +115,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
|
||||
#ifdef LUASOCKET_DEBUG
|
||||
p_timeout tm = timeout_markstart(buf->tm);
|
||||
#else
|
||||
timeout_markstart(buf->tm);
|
||||
timeout_markstart(buf->tm);
|
||||
#endif
|
||||
/* initialize buffer with optional extra prefix
|
||||
* (useful for concatenating previous partial results) */
|
||||
|
@ -353,9 +353,9 @@ void Air::Invert()
|
||||
}
|
||||
|
||||
Air::Air(Simulation & simulation):
|
||||
sim(simulation),
|
||||
airMode(0),
|
||||
ambientAirTemp(295.15f),
|
||||
sim(simulation)
|
||||
ambientAirTemp(295.15f)
|
||||
{
|
||||
//Simulation should do this.
|
||||
make_kernel();
|
||||
|
Loading…
Reference in New Issue
Block a user