merge and fixed unpoppable issue

This commit is contained in:
Anselme FRANÇOIS 2016-05-28 13:31:12 +02:00
commit 2431a91052
6 changed files with 50 additions and 16 deletions

View File

@ -0,0 +1,36 @@
#include <map.h>
#include <cmath>
#include <cstdlib>
#include <algorithm>
// g++ -shared test_library.cpp -o test_library.so -I../src -fPIC
extern "C" void generate(Map *mapPtr)
{
Map &map = *mapPtr;
int w = map.getWidth();
int h = map.getHeight();
int n = map.getNbTeams();
int i, j, k;
for(i=0;i<w;i++){
for(j=0;j<h;j++){
map[i][j].type = GRASS;
}
}
for(i=0; i<n; i++)
map.team(i) = Coord((w/(n*2))*(1+i*2), h/2);
Coord north = Coord(NORTH);
for(i=0; i<n; i++){
// Coord &spawn = map.team(i);
Coord lib(map.team(i));
lib+=north;
lib+=north;
map[map.team(i)].type=SPAWN;
map[map.team(i)].data.nbRes = 1;
map[lib].type=LIBRARY;
map[lib].data.knowledge = new char[LIBRARY_SIZE];
}
}

View File

@ -18,7 +18,7 @@ Map::Map(int nbTeams, int width, int height) :
Map::~Map()
{
delete m_map;
delete[] m_map;
if(m_nbTeams)
delete m_teams;
}

View File

@ -38,7 +38,7 @@ MapScene::~MapScene()
glDeleteVertexArrays(1, &m_vao);
m_vao = 0;
}
delete m_teamColors;
delete[] m_teamColors;
}
void MapScene::updatePixel(const Coord &c)

View File

@ -11,7 +11,7 @@
struct MapScene : public Map, public BasicScene
{
public:
MapScene(int n, int w, int h=0) : Map(n, w, h), m_teamColors(new TeamColor[n]) {}
MapScene(int n, int w, int h=0) : Map(n, w, h), m_teamColors(new TeamColor[n]),m_vao(0),m_vbo(0) {}
~MapScene();

View File

@ -210,8 +210,6 @@ void Simulation::handleAction(const Action &action, Dude *dude)
}
else{
target.writeBook(action.com_data);
// TODO: understand what the fuck this line is doing bis
//memcpy(target.data.knowledge + action->com_data.flag, action->com_data.data, COM_SIZE);
dude->setSuccess(true);
}
break;