ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.322 by root, Sun Nov 18 01:43:12 2018 UTC vs.
Revision 1.323 by root, Sun Nov 18 01:48:39 2018 UTC

199 } 199 }
200 200
201 return 0; 201 return 0;
202} 202}
203 203
204typedef struct cf_layout { 204struct cf_layout {
205 PangoLayout *pl; 205 PangoLayout *pl;
206 float r, g, b, a; // default color for rgba mode 206 float r, g, b, a; // default color for rgba mode
207 int base_height; 207 int base_height;
208 DC__Font font; 208 DC__Font font;
209 rc_t *rc; 209 rc_t *rc;
210} *DC__Layout; 210};
211
212typedef cf_layout *DC__Layout;
211 213
212static DC__Font default_font; 214static DC__Font default_font;
213static PangoContext *opengl_context; 215static PangoContext *opengl_context;
214static PangoFontMap *opengl_fontmap; 216static PangoFontMap *opengl_fontmap;
215 217
256} 258}
257 259
258typedef uint16_t tileid; 260typedef uint16_t tileid;
259typedef uint16_t faceid; 261typedef uint16_t faceid;
260 262
261typedef struct { 263struct maptex
264{
262 GLuint name; 265 GLuint name;
263 int w, h; 266 int w, h;
264 float s, t; 267 float s, t;
265 uint8_t r, g, b, a; 268 uint8_t r, g, b, a;
266 tileid smoothtile; 269 tileid smoothtile;
267 uint8_t smoothlevel; 270 uint8_t smoothlevel;
268 uint8_t unused; /* set to zero on use */ 271 uint8_t unused; /* set to zero on use */
269} maptex; 272};
270 273
271typedef struct { 274struct mapcell
275{
272 uint32_t player; 276 uint32_t player;
273 tileid tile[3]; 277 tileid tile[3];
274 uint16_t darkness; 278 uint16_t darkness;
275 uint8_t stat_width, stat_hp, flags, smoothmax; 279 uint8_t stat_width, stat_hp, flags, smoothmax;
276} mapcell; 280};
277 281
278typedef struct { 282struct maprow
283{
279 int32_t c0, c1; 284 int32_t c0, c1;
280 mapcell *col; 285 mapcell *col;
281} maprow; 286};
282 287
283typedef struct map { 288struct mapgrid {
284 int x, y, w, h; 289 int x, y, w, h;
285 int ox, oy; /* offset to virtual global coordinate system */ 290 int ox, oy; /* offset to virtual global coordinate system */
286 int faces; tileid *face2tile; // [faceid] 291 int faces; tileid *face2tile; // [faceid]
287 int texs; maptex *tex; // [tileid] 292 int texs; maptex *tex; // [tileid]
288 293
289 int32_t rows; 294 int32_t rows;
290 maprow *row; 295 maprow *row;
291} *DC__Map; 296};
297
298typedef mapgrid *DC__Map;
292 299
293static char * 300static char *
294prepend (char *ptr, int sze, int inc) 301prepend (char *ptr, int sze, int inc)
295{ 302{
296 char *p; 303 char *p;
314 321
315#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 322#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
316#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type)) 323#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
317 324
318static void 325static void
319need_facenum (struct map *self, faceid face) 326need_facenum (struct mapgrid *self, faceid face)
320{ 327{
321 while (self->faces <= face) 328 while (self->faces <= face)
322 { 329 {
323 Append (tileid, self->face2tile, self->faces, self->faces); 330 Append (tileid, self->face2tile, self->faces, self->faces);
324 self->faces *= 2; 331 self->faces *= 2;
325 } 332 }
326} 333}
327 334
328static void 335static void
329need_texid (struct map *self, int texid) 336need_texid (struct mapgrid *self, int texid)
330{ 337{
331 while (self->texs <= texid) 338 while (self->texs <= texid)
332 { 339 {
333 Append (maptex, self->tex, self->texs, self->texs); 340 Append (maptex, self->tex, self->texs, self->texs);
334 self->texs *= 2; 341 self->texs *= 2;
335 } 342 }
336} 343}
337 344
338static maprow * 345static maprow *
339map_get_row (DC__Map self, int y) 346map_get_row (mapgrid *self, int y)
340{ 347{
341 if (0 > y) 348 if (0 > y)
342 { 349 {
343 int extend = - y + MAP_EXTEND_Y; 350 int extend = - y + MAP_EXTEND_Y;
344 Prepend (maprow, self->row, self->rows, extend); 351 Prepend (maprow, self->row, self->rows, extend);
382 389
383 return row->col + (x - row->c0); 390 return row->col + (x - row->c0);
384} 391}
385 392
386static mapcell * 393static mapcell *
387map_get_cell (DC__Map self, int x, int y) 394map_get_cell (mapgrid *self, int x, int y)
388{ 395{
389 return row_get_cell (map_get_row (self, y), x); 396 return row_get_cell (map_get_row (self, y), x);
390} 397}
391 398
392static void 399static void
393map_clear (DC__Map self) 400map_clear (mapgrid *self)
394{ 401{
395 int r; 402 int r;
396 403
397 for (r = 0; r < self->rows; r++) 404 for (r = 0; r < self->rows; r++)
398 Safefree (self->row[r].col); 405 Safefree (self->row[r].col);
416 (cell)->flags = 0; \ 423 (cell)->flags = 0; \
417 (cell)->player = 0; \ 424 (cell)->player = 0; \
418 } while (0) 425 } while (0)
419 426
420static void 427static void
421map_blank (DC__Map self, int x0, int y0, int w, int h) 428map_blank (mapgrid *self, int x0, int y0, int w, int h)
422{ 429{
423 int x, y; 430 int x, y;
424 maprow *row; 431 maprow *row;
425 mapcell *cell; 432 mapcell *cell;
426 433
1894PROTOTYPES: DISABLE 1901PROTOTYPES: DISABLE
1895 1902
1896DC::Map 1903DC::Map
1897new (SV *klass) 1904new (SV *klass)
1898 CODE: 1905 CODE:
1899 New (0, RETVAL, 1, struct map); 1906 New (0, RETVAL, 1, mapgrid);
1900 RETVAL->x = 0; 1907 RETVAL->x = 0;
1901 RETVAL->y = 0; 1908 RETVAL->y = 0;
1902 RETVAL->w = 0; 1909 RETVAL->w = 0;
1903 RETVAL->h = 0; 1910 RETVAL->h = 0;
1904 RETVAL->ox = 0; 1911 RETVAL->ox = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines