Accounts e-mail HP

Extended </create player_name nation>

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!

Extended </create player_name nation>

Postby Davide » Wed Dec 19, 2012 3:48 pm

RFC:

Code: Select all
--- originals/freeciv-2.3.2/server/stdinhand.c  2012-03-31 14:32:41.000000000 +0200
+++ create_player/server/stdinhand.c    2012-12-19 15:33:56.000000000 +0100
@@ -975,10 +975,15 @@
 /**************************************************************************
   ...
 **************************************************************************/
-enum rfc_status create_command_pregame(const char *name, bool check,
+enum rfc_status create_command_pregame(const char *who, bool check,
                                        struct player **newplayer,
                                        char *buf, size_t buflen)
 {
+  char *args[2];
+  char *name=NULL, *nation=NULL;
+  get_tokens(who, args, ARRAY_SIZE(args), TOKEN_DELIMITERS);
+  name = args[0], nation = args[1];
+
   struct player *pplayer = NULL;

   if (!player_name_check(name, buf, buflen)) {
@@ -1065,6 +1070,34 @@
   if (newplayer != NULL) {
     *newplayer = pplayer;
   }
+
+  if (nation) {
+    int found = FALSE;
+
+    nations_iterate(pnation) {
+      const struct name_translation *pdemonym = &(pnation->adjective);
+
+      if (strcmp(nation, rule_name(pdemonym)) == 0) {
+       found = TRUE;
+       server_player_set_name(pplayer, name);
+       pplayer->is_male = TRUE;
+       pplayer->city_style = city_style_of_nation(pnation);
+
+       player_set_nation(pplayer, pnation);
+       break;
+      }
+
+    } nations_iterate_end;
+    if (!found) {
+      char msgbuf[MAX_LEN_MSG];
+      strcpy(msgbuf, "WARNING: Nation not found: ");
+      strcat(msgbuf, nation);
+      fc_snprintf(buf, buflen,
+                 _(msgbuf));
+    }
+  }
+
+  free_tokens(args, ARRAY_SIZE(args));
   return C_OK;
 }

User avatar
Davide
 
Posts: 864
Joined: Sat Mar 24, 2012 12:34 am

Return to Contribution

Who is online

Users browsing this forum: No registered users and 2 guests

cron