Server Help

Bot Questions - Error parsing

Anonymous - Fri Dec 03, 2004 6:09 pm
Post subject: Error parsing
Hello,

I'm building a bot but the function doesn't really matter. Anyways, i'm trying to put a _listnode in it but it gives erros all the time. Here's the code and the error:

Code: Show/Hide
               int countnum=0;
               _listnode  *parse1 = playerlist->head;

               {
                  Player *p = parse1->item;

                  if (p->ship != SHIP_Spectator)
                  {
                     pilots[countnum].PlayerCall=String(p->name);
                     countnum++;
                  }

                  parse1 = parse1->next;
               }


Quote:
Compiling...
spawn.cpp
d:\bots\ds soccer\mervbot\src\soccer\spawn.cpp(69) : error C2440: 'initializing' : cannot convert from 'class _listnode<struct Player> *' to 'class _listnode *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\bots\ds soccer\mervbot\src\soccer\spawn.cpp(72) : error C2440: 'initializing' : cannot convert from ' *' to 'struct Player *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\bots\ds soccer\mervbot\src\soccer\spawn.cpp(76) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class String' (or there is no acceptable conversion)
d:\bots\ds soccer\mervbot\src\soccer\spawn.cpp(80) : error C2440: '=' : cannot convert from 'class _listnode<AnonymousStruct> *' to 'class _listnode *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
command.cpp
Error executing cl.exe.

soccer.dll - 4 error(s), 0 warning(s)

Anonymous - Fri Dec 03, 2004 6:22 pm
Post subject:
Quote:
_listnode *parse1 = playerlist->head;
Maybe lose the '*'.

Quote:
pilots[countnum].PlayerCall=String(p->name);

You can't assign a String to PlayerCall, which is interesting as I have seen people post code like:
Code: Show/Hide
String s = "*setfreq ";
s += p->ship;
Where assignment is done.
Cyan~Fire - Fri Dec 03, 2004 6:32 pm
Post subject:
The Arctica wrote:
_listnode *parse1 = playerlist->head;

Actually, you need to specify the struct type. _listnodes can store any kind of data whatever, so (to put it simply), you must tell the compiler what type of stuff you're putting in it right now. Example "_listnode <Player> *parsel;" which is what you need to use here.

The Arctica wrote:
pilots[countnum].PlayerCall=String(p->name);

There's an error there, but what Smong said isn't the problem. What datatype is PlayerCall?
50% Packetloss - Fri Dec 03, 2004 8:37 pm
Post subject:
Code: Show/Hide

int countnum=0;
               _listnode <Player> *parse1 = playerlist->head;

while(parse1 != NULL)
               {
                  Player *p = parse1->item;

                  if (p->ship != SHIP_Spectator)
                  {
                     //pilots[countnum].PlayerCall=String(p->name);

//if PlayerCall is of the type String then you can just do PlayerCall= p->name and it work. Otherwise, if its a char[20] then you use strncpy or strcpy to copy in the player's name. Hopefully there is some control over how many piolets are in the game or you might have a buffer overrun on that pilots array. Dont overindex it!
                     countnum++;
                  }

                  parse1 = parse1->next;
               }

Anonymous - Sat Dec 04, 2004 2:42 am
Post subject: Error parsing
Code: Show/Hide
Compiling...
spawn.cpp
command.cpp
Linking...
   Creating library Debug/soccer.lib and object Debug/soccer.exp

soccer.dll - 0 error(s), 0 warning(s)


Thanks alot guys! icon_biggrin.gif
SuSE - Sat Dec 04, 2004 4:02 am
Post subject:
$3
CypherJF - Sat Dec 04, 2004 11:55 am
Post subject:
When you're finished w/ your plugin, don't compile it w/ DEBUG mode in MSVC
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group