X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Flink%2FC%2Fc_link.c;h=524697d967efcb449a23dfc4524bcfbd4f95c87e;hb=refs%2Ftags%2Fv02.1;hp=39dda6b8e58387da9b9b246ff3d5f9385e250552;hpb=4f032479507641dacc772624c4a6b56a664fb249;p=progcomp10.git diff --git a/src/link/C/c_link.c b/src/link/C/c_link.c index 39dda6b..524697d 100755 --- a/src/link/C/c_link.c +++ b/src/link/C/c_link.c @@ -57,29 +57,26 @@ int main( int argc, char * argv[] ) { srand( time( NULL ) ); char command[MAXCOMMANDLEN]; - char foeName[MAXFOENAMELEN]; + char foeName[MAXAGENTNAMELEN]; char attItem[MAXITEMLEN], defItem[MAXITEMLEN], bluffItem[MAXITEMLEN]; char didYouInstigate[MAXBOOLLEN]; char winner[MAXRESULTLEN]; + char uuid[MAXAGENTNAMELEN]; int pointChange; - void *thisInstance; + void *thisInstance = NULL; ATTACKTYPE attack; ITEMTYPE defence; - /* generate a random id for this bot. Hopefully it's unique - I can't use the UUID, because python doesn't pass it to me! */ - me = rand(); - - // TODO: Get the UUID passed by python - // Currently, just pass an empty string to the initialise function - thisInstance = Initialise( "" ); - scanf( "%s", command ); while (strcasecmp("BYE",command) != 0) { - if (strcasecmp("ATTACK", command) == 0) { + if (strcasecmp("HI", command) == 0) { + scanf( "%s", uuid ); + thisInstance = Initialise( uuid ); + + } else if (strcasecmp("ATTACK", command) == 0) { scanf( "%s", foeName ); attack = Attack( thisInstance, foeName ); printf("ATTACKING %s %s\n", ITEMNAMES[attack.realAttack], ITEMNAMES[attack.promisedAttack]); @@ -104,7 +101,8 @@ int main( int argc, char * argv[] ) { scanf( "%s", command ); } - Cleanup(thisInstance); + if( thisInstance ) + Cleanup(thisInstance); return 0; }