rnd-20050627-1-src
[rocksndiamonds.git] / src / libgame / misc.c
index 59a273e15b6607f5d771123bfec43ca98cfeb2a0..f90b2c23b7b23f1bfb28420f4aac8784a9a31447 100644 (file)
@@ -337,26 +337,24 @@ static char *get_corrected_real_name(char *real_name)
   char *from_ptr = real_name;
   char *to_ptr   = real_name_new;
 
-  if (strchr(real_name, 'ß') == NULL)  /* name does not contain 'ß' */
-  {
-    strncpy(real_name_new, real_name, MAX_USERNAME_LEN);
-    real_name_new[MAX_USERNAME_LEN] = '\0';
-
-    return real_name_new;
-  }
-
-  /* the user's real name may contain a 'ß' character (german sharp s),
-     which has no equivalent in upper case letters (which our fonts use) */
+  /* copy the name string, but not more than MAX_USERNAME_LEN characters */
   while (*from_ptr && (long)(to_ptr - real_name_new) < MAX_USERNAME_LEN - 1)
   {
-    if (*from_ptr != 'ß')
-      *to_ptr++ = *from_ptr++;
-    else
+    /* the name field read from "passwd" file may also contain additional
+       user information, separated by commas, which will be removed here */
+    if (*from_ptr == ',')
+      break;
+
+    /* the user's real name may contain 'ß' characters (german sharp s),
+       which have no equivalent in upper case letters (used by our fonts) */
+    if (*from_ptr == 'ß')
     {
       from_ptr++;
       *to_ptr++ = 's';
       *to_ptr++ = 's';
     }
+    else
+      *to_ptr++ = *from_ptr++;
   }
 
   *to_ptr = '\0';
@@ -2474,6 +2472,12 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
   char *basename = file_list_entry->filename;
   char *filename = getCustomArtworkFilename(basename, artwork_info->type);
 
+#if 0
+  if (strcmp(file_list_entry->token, "background.DOOR") == 0)
+    printf("::: replaceArtworkListEntry: '%s' => '%s'\n",
+          basename, filename);
+#endif
+
   if (filename == NULL)
   {
     Error(ERR_WARN, "cannot find artwork file '%s'", basename);
@@ -2534,6 +2538,11 @@ static void replaceArtworkListEntry(struct ArtworkListInfo *artwork_info,
       return;
   }
 
+#if 0
+  if (strcmp(file_list_entry->token, "background.DOOR") == 0)
+    printf("::: replaceArtworkListEntry: LOAD IT'\n");
+#endif
+
 #if 0
   printf("::: %s: '%s'\n", init_text[artwork_info->type], basename);
 #endif
@@ -2671,6 +2680,12 @@ static void LoadCustomArtwork(struct ArtworkListInfo *artwork_info,
   printf("GOT CUSTOM ARTWORK FILE '%s'\n", filename);
 #endif
 
+#if 0
+  if (strcmp(file_list_entry->token, "background.DOOR") == 0)
+    printf("::: -> '%s' -> '%s'\n",
+          file_list_entry->token, file_list_entry->filename);
+#endif
+
   if (strcmp(file_list_entry->filename, UNDEFINED_FILENAME) == 0)
   {
     deleteArtworkListEntry(artwork_info, listnode);
@@ -2713,7 +2728,7 @@ static void LoadArtworkToList(struct ArtworkListInfo *artwork_info,
 
 #if 0
   printf("loading artwork '%s' ...  [%d]\n",
-        basename, getNumNodes(artwork_info->content_list));
+        file_list_entry->filename, getNumNodes(artwork_info->content_list));
 #endif
 
 #if 1
@@ -2777,7 +2792,7 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
   for (i = 0; i < num_file_list_entries; i++)
   {
 #if 0
-    if (strcmp(file_list[i].token, "background") == 0)
+    if (strcmp(file_list[i].token, "background.DOOR") == 0)
       printf("::: '%s' -> '%s'\n", file_list[i].token, file_list[i].filename);
 #endif
 
@@ -2789,6 +2804,19 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info)
                      file_list[i].filename, i);
 #endif
 
+#if 0
+    if (strcmp(file_list[i].token, "background.DOOR") == 0)
+    {
+      Bitmap *bitmap = getBitmapFromImageID(i);
+
+      printf("::: BITMAP: %08lx\n", bitmap);
+
+#if 0
+      BlitBitmap(bitmap, window, 0, 0, 100, 280, 0, 0);
+#endif
+    }
+#endif
+
 #if 0
     /* !!! NEW ARTWORK FALLBACK CODE !!! NEARLY UNTESTED !!! */
     if (artwork_info->artwork_list[i] == NULL &&