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.328 by root, Sun Nov 18 12:47:55 2018 UTC vs.
Revision 1.329 by root, Sun Nov 18 13:07:51 2018 UTC

296 maprow *row; 296 maprow *row;
297}; 297};
298 298
299typedef mapgrid *DC__Map; 299typedef mapgrid *DC__Map;
300 300
301static char * 301template<typename T>
302static void
302prepend (char *ptr, int sze, int inc) 303prepend (T *&ptr, int sze, int inc)
303{ 304{
304 char *p; 305 T *p;
305 306
306 New (0, p, sze + inc, char); 307 New (0, p, sze + inc, T);
307 Zero (p, inc, char); 308 Zero (p, inc, T);
308 Move (ptr, p + inc, sze, char); 309 Move (ptr, p + inc, sze, T);
309 Safefree (ptr); 310 Safefree (ptr);
310 311
311 return p; 312 ptr = p;
312} 313}
313 314
314static char * 315template<typename T>
316static void
315append (char *ptr, int sze, int inc) 317append (T *&ptr, int sze, int inc)
316{ 318{
317 Renew (ptr, sze + inc, char); 319 Renew (ptr, sze + inc, T);
318 Zero (ptr + sze, inc, char); 320 Zero (ptr + sze, inc, T);
319
320 return ptr;
321} 321}
322
323#define Append(type,ptr,sze,inc) (ptr) = (type *)append ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
324#define Prepend(type,ptr,sze,inc) (ptr) = (type *)prepend ((char *)ptr, (sze) * sizeof (type), (inc) * sizeof (type))
325 322
326static void 323static void
327need_facenum (struct mapgrid *self, faceid face) 324need_facenum (struct mapgrid *self, faceid face)
328{ 325{
329 while (self->faces <= face) 326 while (self->faces <= face)
330 { 327 {
331 Append (tileid, self->face2tile, self->faces, self->faces); 328 append (self->face2tile, self->faces, self->faces);
332 self->faces *= 2; 329 self->faces *= 2;
333 } 330 }
334} 331}
335 332
336static void 333static void
337need_texid (struct mapgrid *self, int texid) 334need_texid (struct mapgrid *self, int texid)
338{ 335{
339 while (self->texs <= texid) 336 while (self->texs <= texid)
340 { 337 {
341 Append (maptex, self->tex, self->texs, self->texs); 338 append (self->tex, self->texs, self->texs);
342 self->texs *= 2; 339 self->texs *= 2;
343 } 340 }
344} 341}
345 342
346static maprow * 343static maprow *
347map_get_row (mapgrid *self, int y) 344map_get_row (mapgrid *self, int y)
348{ 345{
349 if (0 > y) 346 if (0 > y)
350 { 347 {
351 int extend = - y + MAP_EXTEND_Y; 348 int extend = - y + MAP_EXTEND_Y;
352 Prepend (maprow, self->row, self->rows, extend); 349 prepend (self->row, self->rows, extend);
353 350
354 self->rows += extend; 351 self->rows += extend;
355 self->y += extend; 352 self->y += extend;
356 y += extend; 353 y += extend;
357 } 354 }
358 else if (y >= self->rows) 355 else if (y >= self->rows)
359 { 356 {
360 int extend = y - self->rows + MAP_EXTEND_Y; 357 int extend = y - self->rows + MAP_EXTEND_Y;
361 Append (maprow, self->row, self->rows, extend); 358 append (self->row, self->rows, extend);
362 self->rows += extend; 359 self->rows += extend;
363 } 360 }
364 361
365 return self->row + y; 362 return self->row + y;
366} 363}
376 } 373 }
377 374
378 if (row->c0 > x) 375 if (row->c0 > x)
379 { 376 {
380 int extend = row->c0 - x + MAP_EXTEND_X; 377 int extend = row->c0 - x + MAP_EXTEND_X;
381 Prepend (mapcell, row->col, row->c1 - row->c0, extend); 378 prepend (row->col, row->c1 - row->c0, extend);
382 row->c0 -= extend; 379 row->c0 -= extend;
383 } 380 }
384 else if (x >= row->c1) 381 else if (x >= row->c1)
385 { 382 {
386 int extend = x - row->c1 + MAP_EXTEND_X; 383 int extend = x - row->c1 + MAP_EXTEND_X;
387 Append (mapcell, row->col, row->c1 - row->c0, extend); 384 append (row->col, row->c1 - row->c0, extend);
388 row->c1 += extend; 385 row->c1 += extend;
389 } 386 }
390 387
391 return row->col + (x - row->c0); 388 return row->col + (x - row->c0);
392} 389}
2056 self->ox += dx; self->x += dx; 2053 self->ox += dx; self->x += dx;
2057 self->oy += dy; self->y += dy; 2054 self->oy += dy; self->y += dy;
2058 2055
2059 while (self->y < 0) 2056 while (self->y < 0)
2060 { 2057 {
2061 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); 2058 prepend (self->row, self->rows, MAP_EXTEND_Y);
2062 2059
2063 self->rows += MAP_EXTEND_Y; 2060 self->rows += MAP_EXTEND_Y;
2064 self->y += MAP_EXTEND_Y; 2061 self->y += MAP_EXTEND_Y;
2065 } 2062 }
2066} 2063}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines