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.326 by root, Sun Nov 18 03:06:13 2018 UTC vs.
Revision 1.330 by root, Sun Nov 18 15:24:24 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 Newxz (p, sze + inc, T);
307 Zero (p, inc, char);
308 Move (ptr, p + inc, sze, char); 308 Move (ptr, p + inc, sze, T);
309 Safefree (ptr); 309 Safefree (ptr);
310 310
311 return p; 311 ptr = p;
312} 312}
313 313
314static char * 314template<typename T>
315static void
315append (char *ptr, int sze, int inc) 316append (T *&ptr, int sze, int inc)
316{ 317{
317 Renew (ptr, sze + inc, char); 318 Renew (ptr, sze + inc, T);
318 Zero (ptr + sze, inc, char); 319 Zero (ptr + sze, inc, T);
319
320 return ptr;
321} 320}
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 321
326static void 322static void
327need_facenum (struct mapgrid *self, faceid face) 323need_facenum (struct mapgrid *self, faceid face)
328{ 324{
329 while (self->faces <= face) 325 while (self->faces <= face)
330 { 326 {
331 Append (tileid, self->face2tile, self->faces, self->faces); 327 append (self->face2tile, self->faces, self->faces);
332 self->faces *= 2; 328 self->faces *= 2;
333 } 329 }
334} 330}
335 331
336static void 332static void
337need_texid (struct mapgrid *self, int texid) 333need_texid (struct mapgrid *self, int texid)
338{ 334{
339 while (self->texs <= texid) 335 while (self->texs <= texid)
340 { 336 {
341 Append (maptex, self->tex, self->texs, self->texs); 337 append (self->tex, self->texs, self->texs);
342 self->texs *= 2; 338 self->texs *= 2;
343 } 339 }
344} 340}
345 341
346static maprow * 342static maprow *
347map_get_row (mapgrid *self, int y) 343map_get_row (mapgrid *self, int y)
348{ 344{
349 if (0 > y) 345 if (0 > y)
350 { 346 {
351 int extend = - y + MAP_EXTEND_Y; 347 int extend = - y + MAP_EXTEND_Y;
352 Prepend (maprow, self->row, self->rows, extend); 348 prepend (self->row, self->rows, extend);
353 349
354 self->rows += extend; 350 self->rows += extend;
355 self->y += extend; 351 self->y += extend;
356 y += extend; 352 y += extend;
357 } 353 }
358 else if (y >= self->rows) 354 else if (y >= self->rows)
359 { 355 {
360 int extend = y - self->rows + MAP_EXTEND_Y; 356 int extend = y - self->rows + MAP_EXTEND_Y;
361 Append (maprow, self->row, self->rows, extend); 357 append (self->row, self->rows, extend);
362 self->rows += extend; 358 self->rows += extend;
363 } 359 }
364 360
365 return self->row + y; 361 return self->row + y;
366} 362}
376 } 372 }
377 373
378 if (row->c0 > x) 374 if (row->c0 > x)
379 { 375 {
380 int extend = row->c0 - x + MAP_EXTEND_X; 376 int extend = row->c0 - x + MAP_EXTEND_X;
381 Prepend (mapcell, row->col, row->c1 - row->c0, extend); 377 prepend (row->col, row->c1 - row->c0, extend);
382 row->c0 -= extend; 378 row->c0 -= extend;
383 } 379 }
384 else if (x >= row->c1) 380 else if (x >= row->c1)
385 { 381 {
386 int extend = x - row->c1 + MAP_EXTEND_X; 382 int extend = x - row->c1 + MAP_EXTEND_X;
387 Append (mapcell, row->col, row->c1 - row->c0, extend); 383 append (row->col, row->c1 - row->c0, extend);
388 row->c1 += extend; 384 row->c1 += extend;
389 } 385 }
390 386
391 return row->col + (x - row->c0); 387 return row->col + (x - row->c0);
392} 388}
2056 self->ox += dx; self->x += dx; 2052 self->ox += dx; self->x += dx;
2057 self->oy += dy; self->y += dy; 2053 self->oy += dy; self->y += dy;
2058 2054
2059 while (self->y < 0) 2055 while (self->y < 0)
2060 { 2056 {
2061 Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); 2057 prepend (self->row, self->rows, MAP_EXTEND_Y);
2062 2058
2063 self->rows += MAP_EXTEND_Y; 2059 self->rows += MAP_EXTEND_Y;
2064 self->y += MAP_EXTEND_Y; 2060 self->y += MAP_EXTEND_Y;
2065 } 2061 }
2066} 2062}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines