Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2000:
[Freeciv-Dev] Win32 patch
Home

[Freeciv-Dev] Win32 patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mike_jing@xxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Win32 patch
From: akemnade@xxxxxxxxxxx (Andreas Kemnade)
Date: Sat, 26 Feb 2000 20:01:59 +0100 (CET)

Mike Jing writes:
 > I downloaded the precompiled version, but the client doesn't work.  I ran it 
 > on Win98 (1st ed.).  Error messages are attched.
 > 
I have tested on Win98 today and got the same errors. I have found a
quick hack to make it run on win98. Pixmaps are allocated when used
now. You can download the new version.


Here is the quick hack. It also fixes a problem in the server.
Perhaps it can be done in a cleaner way.

--- freeciv/client/tilespec.c   Sun Jan 23 12:50:51 2000
+++ freeciv-win/client/tilespec.c       Sat Feb 26 13:12:02 2000
@@ -73,6 +73,17 @@
    the things stored by tile_sprites, not pointers into
    the tile_sprites array itself).
 */
+#if WIN32
+struct SpriteData {
+  struct Sprite *source;
+  int x;
+  int y;
+  int w;
+  int h;
+  
+};
+struct SpriteData sprite_d[4000];
+#endif
 static struct Sprite **tile_sprites;
 static struct athing atile_sprites;   /* .ptr is tile_sprites */
 
@@ -124,10 +135,27 @@
   }
   ath_minnum(&atile_sprites, atile_sprites.n+1);
   tile_sprites = atile_sprites.ptr;
+#ifdef WIN32
+  sprite_d[atile_sprites.n-1].x=x;
+  sprite_d[atile_sprites.n-1].y=y;
+  sprite_d[atile_sprites.n-1].w=dx;
+  sprite_d[atile_sprites.n-1].h=dy;
+  sprite_d[atile_sprites.n-1].source=source;
+  tile_sprites[atile_sprites.n-1] = NULL;
+#else
   tile_sprites[atile_sprites.n-1] = crop_sprite(source, x, y, dx, dy);
+#endif
   return atile_sprites.n-1;
 }
-
+#ifdef WIN32
+struct Sprite *win_get_tile(int i)
+{
+  
+    if (tile_sprites[i]==NULL) 
+      
tile_sprites[i]=crop_sprite(sprite_d[i].source,sprite_d[i].x,sprite_d[i].y,sprite_d[i].w,sprite_d[i].h);
+    return tile_sprites[i];
+}
+#endif
 /**********************************************************************
   Reallocs tile_sprites exactly to current size;
   Do this at the end to avoid "permanent" waste.
@@ -388,9 +416,9 @@
     }
   }
   free(gridnames);
-
+#ifndef WIN32
   free_sprite(big_sprite);
-  
+#endif  
   section_file_check_unused(file, spec_filename);
   section_file_free(file);
   freelog(LOG_DEBUG, "finished %s", spec_filename);
@@ -410,9 +438,13 @@
 }
      
 /* Note very safe, but convenient: */
+#ifdef WIN32
+#define SET_SPRITE(field,tag) \
+sprites.field=win_get_tile(secfile_lookup_int(&tag_sf, "%s", (tag)));
+#else
 #define SET_SPRITE(field, tag) \
     sprites.field = tile_sprites[secfile_lookup_int(&tag_sf, "%s", (tag))]
-
+#endif
 /**********************************************************************
   Initialize 'sprites' structure based on hardwired tags which
   freeciv always requires. 
@@ -621,6 +653,10 @@
   i = secfile_lookup_int_default(&tag_sf, -1, "%s", tag);
   if (i != -1) {
     assert(i>=0 && i<atile_sprites.n);
+#ifdef WIN32
+    if (tile_sprites[i]==NULL) {
+      
tile_sprites[i]=crop_sprite(sprite_d[i].source,sprite_d[i].x,sprite_d[i].y,sprite_d[i].w,sprite_d[i].h);
 }
+#endif
     return tile_sprites[i];
   }
   
@@ -629,6 +665,10 @@
     assert(i>=0 && i<atile_sprites.n);
     freelog(loglevel, "Using alternate graphic %s (instead of %s) for %s %s",
            alt, tag, what, name);
+#ifdef WIN32
+    if (tile_sprites[i]==NULL) {
+      
tile_sprites[i]=crop_sprite(sprite_d[i].source,sprite_d[i].x,sprite_d[i].y,sprite_d[i].w,sprite_d[i].h);
 }
+#endif
     return tile_sprites[i];
   }
   
@@ -1177,6 +1217,10 @@
   for(j=0; j<32 && city_styles[style].tiles_num < MAX_CITY_TILES; j++) {
     sprite_idx = secfile_lookup_int_default( &tag_sf, -1, "%s_%d", graphics, 
j);
     if( sprite_idx != -1 ) {
+#ifdef WIN32
+    if (tile_sprites[sprite_idx]==NULL) {
+      
tile_sprites[sprite_idx]=crop_sprite(sprite_d[sprite_idx].source,sprite_d[sprite_idx].x,sprite_d[sprite_idx].y,sprite_d[sprite_idx].w,sprite_d[sprite_idx].h);
 }
+#endif
       sprites.city.tile[style][city_styles[style].tiles_num] = 
tile_sprites[sprite_idx];
       city_styles[style].tresh[city_styles[style].tiles_num] = j;
       city_styles[style].tiles_num++;
@@ -1189,15 +1233,26 @@
 
   /* the wall tile */
   sprite_idx = secfile_lookup_int_default( &tag_sf, -1, "%s_wall", graphics);
-  if( sprite_idx != -1 )
+  if( sprite_idx != -1 ) {
+#ifdef WIN32
+    if (tile_sprites[sprite_idx]==NULL) {
+      
tile_sprites[sprite_idx]=crop_sprite(sprite_d[sprite_idx].source,sprite_d[sprite_idx].x,sprite_d[sprite_idx].y,sprite_d[sprite_idx].w,sprite_d[sprite_idx].h);
 }
+#endif
     sprites.city.tile[style][city_styles[style].tiles_num] = 
tile_sprites[sprite_idx];
+  }
   else
     freelog(LOG_NORMAL, "Warning: no wall tile for graphic %s", graphics);
 
   /* occupied tile */
   sprite_idx = secfile_lookup_int_default( &tag_sf, -1, "%s_occupied", 
graphics);
   if( sprite_idx != -1 )
-    sprites.city.tile[style][city_styles[style].tiles_num+1] = 
tile_sprites[sprite_idx];
+    {
+#ifdef WIN32
+      if (tile_sprites[sprite_idx]==NULL) {
+       
tile_sprites[sprite_idx]=crop_sprite(sprite_d[sprite_idx].source,sprite_d[sprite_idx].x,sprite_d[sprite_idx].y,sprite_d[sprite_idx].w,sprite_d[sprite_idx].h);
 }
+#endif
+      sprites.city.tile[style][city_styles[style].tiles_num+1] = 
tile_sprites[sprite_idx];
+    }
   else
     freelog(LOG_NORMAL, "Warning: no occupied tile for graphic %s", graphics);
 }
@@ -1206,6 +1261,7 @@
   Set city tiles sprite values; should only happen after
   tilespec_load_tiles().
 ***********************************************************************/
+
 void tilespec_setup_city_tiles(int style)
 {
   tilespec_setup_style_tile(style, city_styles[style].graphic);
@@ -1223,13 +1279,21 @@
     freelog(LOG_NORMAL,
            "No tiles for alternate %s style, using default tiles",
             city_styles[style].graphic_alt);
-
+#ifdef WIN32
+    sprites.city.tile[style][0] =
+      win_get_tile(secfile_lookup_int( &tag_sf, "cd.city"));
+    sprites.city.tile[style][1] =
+      win_get_tile(secfile_lookup_int( &tag_sf, "cd.city_wall"));
+    sprites.city.tile[style][2] =
+      win_get_tile(secfile_lookup_int( &tag_sf, "cd.occupied"));
+#else
     sprites.city.tile[style][0] =
       tile_sprites[secfile_lookup_int( &tag_sf, "cd.city")];
     sprites.city.tile[style][1] =
       tile_sprites[secfile_lookup_int( &tag_sf, "cd.city_wall")];
     sprites.city.tile[style][2] =
       tile_sprites[secfile_lookup_int( &tag_sf, "cd.occupied")];
+#endif
     city_styles[style].tiles_num = 1;
     city_styles[style].tresh[0] = 0;
   }
@@ -1275,3 +1339,6 @@
 {
   return COLOR_STD_RACE0 + (pplayer->player_no % MAX_NUM_PLAYERS);
 }
+
+
+
--- freeciv/server/meta.c       Thu Jan  6 12:50:31 2000
+++ freeciv-win/server/meta.c   Sat Feb 26 12:52:38 2000
@@ -56,7 +56,10 @@
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif 
-
+#ifdef WIN32
+#include <windows.h>
+#include <Windows32/Sockets.h>
+#endif                           
 #ifdef HAVE_OPENTRANSPORT
 #include <OpenTransport.h>
 #include <OpenTptInternet.h>
@@ -152,7 +155,11 @@
 #else
   if(sockfd<=0)
     return;
+#ifdef WIN32
+  closesocket(sockfd);
+#else
   close(sockfd);
+#endif
   sockfd=0;
 #endif
 }


  



[Prev in Thread] Current Thread [Next in Thread]