merge and fixed unpoppable issue
This commit is contained in:
commit
2431a91052
@ -7,25 +7,25 @@
|
||||
|
||||
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;
|
||||
Map &map = *mapPtr;
|
||||
int w = map.getWidth();
|
||||
int h = map.getHeight();
|
||||
int n = map.getNbTeams();
|
||||
int i, j, k;
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
map.team(i) = Coord((w/(n*2))*(1+i*2), h/2);
|
||||
for(i=0; i<n; i++)
|
||||
map.team(i) = Coord((w/(n*2))*(1+i*2), h/2);
|
||||
|
||||
int r = h;
|
||||
if(n != 0)
|
||||
r = (w/n < h ? w/n : h)/2;
|
||||
int r = h;
|
||||
if(n != 0)
|
||||
r = (w/n < h ? w/n : h)/2;
|
||||
|
||||
//génération de la carte
|
||||
for (i=0;i<w;i++){
|
||||
for(j=0;j<h;j++){
|
||||
int d = std::max(w, h);
|
||||
if(n == 0)
|
||||
d = h;
|
||||
d = h;
|
||||
for(k=0; k<n; k++){
|
||||
d = std::min(d, map.team(k).dist(i, j));
|
||||
if(!d)
|
||||
|
36
generators/test_library.cpp
Normal file
36
generators/test_library.cpp
Normal 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];
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user