aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorQAston <qaston@gmail.com>2011-09-01 10:46:15 +0200
committerQAston <qaston@gmail.com>2011-09-01 10:46:15 +0200
commit68037cdc3ce4d4c296cf2fd4a0193bc89324568e (patch)
tree106f2760fc025c0889ad92a44f03e2e2b7b45d2a /src/server/scripts/Commands
parent71b9e0d8de4d98fde3ca6440a4f8722ea090d5b8 (diff)
Scripts/Commands: Allow c++ style comments in opcode.txt file for .debug send opcode command.
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp64
1 files changed, 53 insertions, 11 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index ec96aa0ee65..55b85a888d2 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -261,15 +261,58 @@ public:
if (ifs.bad())
return false;
+ // remove comments from file
+ std::stringstream parsedStream;
+ while (!ifs.eof())
+ {
+ char commentToken[2];
+ ifs.get(commentToken[0]);
+ if (commentToken[0] == '/' && !ifs.eof())
+ {
+ ifs.get(commentToken[1]);
+ // /* comment
+ if (commentToken[1] == '*')
+ {
+ while (!ifs.eof())
+ {
+ ifs.get(commentToken[0]);
+ if (commentToken[0] == '*' && !ifs.eof())
+ {
+ ifs.get(commentToken[1]);
+ if (commentToken[1] == '/')
+ break;
+ else
+ ifs.putback(commentToken[1]);
+ }
+ }
+ continue;
+ }
+ // line comment
+ else if (commentToken[1] == '/')
+ {
+ std::string str;
+ getline(ifs,str);
+ continue;
+ }
+ // regular data
+ else
+ {
+ ifs.putback(commentToken[1]);
+ }
+ }
+ parsedStream.put(commentToken[0]);
+ }
+ ifs.close();
+
uint32 opcode;
- ifs >> opcode;
+ parsedStream >> opcode;
WorldPacket data(opcode, 0);
- while (!ifs.eof())
+ while (!parsedStream.eof())
{
std::string type;
- ifs >> type;
+ parsedStream >> type;
if (type == "")
break;
@@ -277,37 +320,37 @@ public:
if (type == "uint8")
{
uint16 val1;
- ifs >> val1;
+ parsedStream >> val1;
data << uint8(val1);
}
else if (type == "uint16")
{
uint16 val2;
- ifs >> val2;
+ parsedStream >> val2;
data << val2;
}
else if (type == "uint32")
{
uint32 val3;
- ifs >> val3;
+ parsedStream >> val3;
data << val3;
}
else if (type == "uint64")
{
uint64 val4;
- ifs >> val4;
+ parsedStream >> val4;
data << val4;
}
else if (type == "float")
{
float val5;
- ifs >> val5;
+ parsedStream >> val5;
data << val5;
}
else if (type == "string")
{
std::string val6;
- ifs >> val6;
+ parsedStream >> val6;
data << val6;
}
else if (type == "appitsguid")
@@ -350,7 +393,7 @@ public:
{
data << uint64(unit->GetGUID());
}
- else if (type == "pos")
+ else if (type == "itspos")
{
data << unit->GetPositionX();
data << unit->GetPositionY();
@@ -368,7 +411,6 @@ public:
break;
}
}
- ifs.close();
sLog->outDebug(LOG_FILTER_NETWORKIO, "Sending opcode %u", data.GetOpcode());
data.hexlike();
player->GetSession()->SendPacket(&data);