project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
branchios-revival
changeset 11245 e7bae160b73b
parent 11244 57891137ffef
child 11560 b96080df19d0
--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Sat Oct 24 15:27:47 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Sat Oct 24 16:01:19 2015 +0200
@@ -341,17 +341,23 @@
                 NSString *tempStr = [NSString stringWithUTF8String:&buffer[2]];
                 NSArray *info = [tempStr componentsSeparatedByString:@" "];
                 NSString *arg = [info objectAtIndex:0];
-                int index = [arg length] + 3;
+                int index = [arg lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 3;
                 switch (buffer[1]) {
                     case 'r':           // winning team
                         [statsArray insertObject:[NSString stringWithUTF8String:&buffer[2]] atIndex:1];
                         break;
                     case 'D':           // best shot
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best shot award won by %s (with %@ points)", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best shot award won by %@ (with %@ points)", nil), hogName, arg]];
                         break;
+                    }
                     case 'k':           // best hedgehog
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best killer is %s with %@ kill(s) in a turn", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best killer is %@ with %@ kill(s) in a turn", nil), hogName, arg]];
                         break;
+                    }
                     case 'K':           // number of hogs killed
                         [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ hedgehog(s) were killed during this round", nil), arg]];
                         break;
@@ -364,14 +370,23 @@
                         [[statsArray objectAtIndex:0] addObject:tempStr];
                         break;
                     case 's':           // self damage
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%s thought it's good to shoot his own hedgehogs with %@ points", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ thought it's good to shoot his own hedgehogs with %@ points", nil), hogName, arg]];
                         break;
+                    }
                     case 'S':           // friendly fire
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%s killed %@ of his own hedgehogs", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ killed %@ of his own hedgehogs", nil), hogName, arg]];
                         break;
+                    }
                     case 'B':           // turn skipped
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%s was scared and skipped turn %@ times", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ was scared and skipped turn %@ times", nil), hogName, arg]];
                         break;
+                    }
                     default:
                         DLog(@"Unhandled stat message, see statsPage.cpp");
                         break;