Attempt at fixing memory mess.
[progcomp10.git] / src / link / C / c_link.c
index 6aa5709..524697d 100755 (executable)
@@ -57,21 +57,17 @@ int main( int argc, char * argv[] ) {
        srand( time( NULL ) );\r
        \r
        char command[MAXCOMMANDLEN];\r
-       char foeName[MAXFOENAMELEN];\r
+       char foeName[MAXAGENTNAMELEN];\r
        char attItem[MAXITEMLEN], defItem[MAXITEMLEN], bluffItem[MAXITEMLEN];\r
        char didYouInstigate[MAXBOOLLEN];\r
        char winner[MAXRESULTLEN];\r
-       char uuid[UUIDLEN];  \r
+       char uuid[MAXAGENTNAMELEN];  \r
        int pointChange;\r
        void *thisInstance = NULL;\r
 \r
        ATTACKTYPE attack;\r
        ITEMTYPE defence;\r
        \r
-       /* generate a random id for this bot. Hopefully it's unique\r
-          I can't use the UUID, because python doesn't pass it to me! */\r
-       me = rand();\r
-       \r
        scanf( "%s", command );\r
        \r
        while (strcasecmp("BYE",command) != 0) {\r
@@ -79,23 +75,20 @@ int main( int argc, char * argv[] ) {
                if (strcasecmp("HI", command) == 0) {\r
                        scanf( "%s", uuid );\r
                        thisInstance = Initialise( uuid );\r
-               }\r
-               else if (strcasecmp("ATTACK", command) == 0) {\r
+                       \r
+               else if (strcasecmp("ATTACK", command) == 0) {\r
                        scanf( "%s", foeName );\r
-                       if( !thisInstance )     break;\r
                        attack = Attack( thisInstance, foeName );\r
                        printf("ATTACKING %s %s\n", ITEMNAMES[attack.realAttack], ITEMNAMES[attack.promisedAttack]);\r
                \r
                } else if (strcasecmp("DEFEND", command) == 0) {\r
                        scanf( "%s %s", foeName, bluffItem );\r
-                       if( !thisInstance )     break;\r
                        defence = Defend(thisInstance, foeName, stringToItem(bluffItem));\r
                        printf("DEFENDING %s\n", ITEMNAMES[defence]);\r
                \r
                } else if (strcasecmp("RESULTS", command) == 0) {\r
                        /* (foeName, isInstigatedByYou, winner, attItem, defItem, bluffItem, pointDelta) */\r
                        scanf( "%s %s %s %s %s %s %d", foeName, didYouInstigate, winner, attItem, defItem, bluffItem, &pointChange );\r
-                       if( !thisInstance )     break;\r
                        Results(thisInstance, foeName, (strcasecmp("True",didYouInstigate)==0), stringToResult(winner),\r
                                        stringToItem(attItem), stringToItem(defItem), stringToItem(bluffItem), pointChange);\r
                        printf("OK\n");\r
@@ -108,7 +101,7 @@ int main( int argc, char * argv[] ) {
                scanf( "%s", command );\r
        }\r
        \r
-       if( !thisInstance )\r
+       if( thisInstance )\r
                Cleanup(thisInstance);\r
        \r
        return 0;\r

UCC git Repository :: git.ucc.asn.au