~ubuntu-branches/ubuntu/maverick/crossfire-client/maverick

« back to all changes in this revision

Viewing changes to gtk/map.c

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2007-04-13 21:15:44 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070413211544-vjo6zesj6g0wgmwf
Tags: 1.10.0-1
* New upstream release
* Install the README, README-dev and TODO files specific to the GTK2
  client to the corresponding package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
const char *rcsid_gtk_map_c =
2
 
    "$Id: map.c,v 1.31 2006/02/23 20:18:28 akirschbaum Exp $";
 
2
    "$Id: map.c 5088 2006-11-06 05:54:03Z mwedel $";
3
3
/*
4
4
    Crossfire client, a client program for the crossfire program.
5
5
 
77
77
    cs_print_string(csocket.fd, "mapredraw");
78
78
}
79
79
    
80
 
static void draw_pixmap(int srcx, int srcy, int dstx, int dsty, int clipx, int clipy, void *mask, void *image)
 
80
static void draw_pixmap(int srcx, int srcy, int dstx, int dsty, int clipx, int clipy,
 
81
                        void *mask, void *image, int sizex, int sizey)
81
82
{
82
83
    gdk_gc_set_clip_mask(mapgc, mask);
83
84
    gdk_gc_set_clip_origin(mapgc, clipx, clipy);
84
 
    gdk_draw_pixmap(mapwindow, mapgc, image, srcx, srcy, dstx, dsty, map_image_size, map_image_size);
 
85
    gdk_draw_pixmap(mapwindow, mapgc, image, srcx, srcy, dstx, dsty, sizex, sizey);
85
86
}
86
87
 
87
88
int display_mapscroll(int dx, int dy)
200
201
                weight*map_image_size, 0,
201
202
                picx, picy,
202
203
                picx-weight*map_image_size, picy,
203
 
                pixmaps[smoothface]->map_mask, pixmaps[smoothface]->map_image);
 
204
                pixmaps[smoothface]->map_mask, pixmaps[smoothface]->map_image, map_image_size, map_image_size);
204
205
        }
205
206
        if (weightC>0){
206
207
            draw_pixmap(
207
208
                weightC*map_image_size, map_image_size,
208
209
                picx, picy,
209
210
                picx-weightC*map_image_size, picy-map_image_size,
210
 
                pixmaps[smoothface]->map_mask, pixmaps[smoothface]->map_image);
 
211
                pixmaps[smoothface]->map_mask, pixmaps[smoothface]->map_image, map_image_size, map_image_size);
211
212
        }
212
213
    }/*while there's some smooth to do*/
213
214
}
244
245
                    w-map_image_size, h-map_image_size,
245
246
                    ax*map_image_size, ay*map_image_size,
246
247
                    ax*map_image_size+map_image_size-w, ay*map_image_size+map_image_size-h,
247
 
                    pixmaps[face]->map_mask, pixmaps[face]->map_image);
 
248
                    pixmaps[face]->map_mask, pixmaps[face]->map_image, map_image_size, map_image_size);
248
249
 
249
250
                if ( use_config[CONFIG_SMOOTH])
250
251
                    drawsmooth(mx, my, layer, ax*map_image_size, ay*map_image_size);
260
261
            /* draw big faces last (should overlap other objects) */
261
262
            face = mapdata_bigface(ax, ay, layer, &sx, &sy);
262
263
            if (face > 0 && pixmaps[face]->map_image != NULL) {
 
264
                /* This is pretty messy, because images are not required to be
 
265
                 * an integral multiplier of the image size.  There
 
266
                 * are really 4 main variables:
 
267
                 * source[xy]: From where within the pixmap to start grabbing pixels.
 
268
                 * off[xy]: Offset from space edge on the visible map to start drawing pixels.
 
269
                 *   off[xy] also determines how many pixels to draw (map_image_size - off[xy])
 
270
                 * clip[xy]: Position of the clipmask.  The position of the clipmask is always
 
271
                 *   at the upper left of the image as we drawn it on the map, so for any
 
272
                 *   given big image, it will have the same values for all the pieces.  However
 
273
                 *   we need to re-construct that location based on current location.
 
274
                 *
 
275
                 * For a 32x72 image, it would be drawn like follows:
 
276
                 *                  sourcey         offy
 
277
                 * top space:       0               24
 
278
                 * middle space:    8               0
 
279
                 * bottom space:    40              0
 
280
                 */
 
281
                int dx, dy, sourcex, sourcey, offx, offy, clipx, clipy;
 
282
 
 
283
                dx = pixmaps[face]->map_width % map_image_size;
 
284
                offx = dx?(map_image_size -dx):0;
 
285
                clipx = (ax - sx)*map_image_size + offx;
 
286
 
 
287
                if (sx) {
 
288
                    sourcex = sx * map_image_size - offx ;
 
289
                    offx=0;
 
290
                } else {
 
291
                    sourcex=0;
 
292
                }
 
293
 
 
294
                dy = pixmaps[face]->map_height % map_image_size;
 
295
                offy = dy?(map_image_size -dy):0;
 
296
                clipy = (ay - sy)*map_image_size + offy;
 
297
 
 
298
                if (sy) {
 
299
                    sourcey = sy * map_image_size - offy;
 
300
                    offy=0;
 
301
                } else {
 
302
                    sourcey=0;
 
303
                }
 
304
 
263
305
                draw_pixmap(
264
 
                    sx*map_image_size, sy*map_image_size,
265
 
                    ax*map_image_size, ay*map_image_size,
266
 
                    (ax-sx)*map_image_size, (ay-sy)*map_image_size,
267
 
                    pixmaps[face]->map_mask, pixmaps[face]->map_image);
 
306
                    sourcex,  sourcey,
 
307
                    ax*map_image_size+offx, ay*map_image_size + offy,
 
308
                    clipx, clipy,
 
309
                    pixmaps[face]->map_mask, pixmaps[face]->map_image,
 
310
                    map_image_size - offx, map_image_size - offy);
268
311
            }
269
312
        } /* else for processing the layers */
270
313
    }
274
317
     * fog cell.
275
318
     */
276
319
    if (use_config[CONFIG_FOGWAR] && the_map.cells[mx][my].cleared) {
277
 
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark1, dark);
 
320
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark1, dark, map_image_size, map_image_size);
278
321
    }
279
322
    else if (the_map.cells[mx][my].darkness > 192) { /* Full dark */
280
323
        gdk_draw_rectangle (mapwindow, drawingarea->style->black_gc,
281
324
            TRUE,map_image_size*ax, map_image_size*ay,
282
325
            map_image_size, map_image_size);
283
326
    } else if (the_map.cells[mx][my].darkness> 128) {
284
 
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark1, dark);
 
327
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark1, dark, map_image_size, map_image_size);
285
328
    } else if (the_map.cells[mx][my].darkness> 64) {
286
 
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark2, dark);
 
329
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark2, dark, map_image_size, map_image_size);
287
330
    } else if (the_map.cells[mx][my].darkness> 1) {
288
 
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark3, dark);
 
331
        draw_pixmap(0, 0, ax*map_image_size, ay*map_image_size, ax*map_image_size, ay*map_image_size, dark3, dark, map_image_size, map_image_size);
289
332
    }
290
333
}
291
334