#652: New map/savegame format
---------------------------------+------------------------------------------
Reporter: Per | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: 2.3
Component: Data: Maps | Version: svn/trunk
Keywords: savegame map editor | Operating_system: All/Non-Specific
Blockedby: | Blocking:
---------------------------------+------------------------------------------
Comment(by anonymous):
Nice Work!
I have a idea to make it a little bit faster.
You use (with*height) often.
Calculate it first like that:
int weidth_height=witdth*height;
terrain = malloc(weidth_height * 2);
heightmap = malloc(weidth_height);
rotate = malloc(weidth_height * 2);
flip = malloc(weidth_height);
for (i = 0; i < weidth_height; i++)
{
heightmap[i] = psTile->height;
terrain[i] = psTile->texture & TILE_NUMMASK;
rotate[i] = ((psTile->texture & TILE_ROTMASK) >> TILE_ROTSHIFT) * 90;
flip[i] = TRI_FLIPPED(psTile) ? 255 : 0;
psTile++;
}
It is more easy to verify that all is correct free after maloc if it is
made in the same sequence.
4742 terrain = malloc(width * height * 2);
4743 heightmap = malloc(width * height);
4744 rotate = malloc(width * height * 2);
4745 flip = malloc(width * height);
...
4767 free(terrain);
4768 free(heightmap);
4769 free(rotate);
4770 free(flip);
Insted of:
4768 free(heightmap);
4768 free(terrain);
4769 free(rotate);
4770 free(flip);
Nice Work. Thanks!
--
Ticket URL: <http://developer.wz2100.net/ticket/652#comment:3>
Warzone 2100 Trac <http://developer.wz2100.net/>
The Warzone 2100 Resurrection Project
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev