merge and fixed unpoppable issue
This commit is contained in:
commit
2431a91052
@ -7,25 +7,25 @@
|
|||||||
|
|
||||||
extern "C" void generate(Map *mapPtr)
|
extern "C" void generate(Map *mapPtr)
|
||||||
{
|
{
|
||||||
Map &map = *mapPtr;
|
Map &map = *mapPtr;
|
||||||
int w = map.getWidth();
|
int w = map.getWidth();
|
||||||
int h = map.getHeight();
|
int h = map.getHeight();
|
||||||
int n = map.getNbTeams();
|
int n = map.getNbTeams();
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
for(i=0; i<n; i++)
|
for(i=0; i<n; i++)
|
||||||
map.team(i) = Coord((w/(n*2))*(1+i*2), h/2);
|
map.team(i) = Coord((w/(n*2))*(1+i*2), h/2);
|
||||||
|
|
||||||
int r = h;
|
int r = h;
|
||||||
if(n != 0)
|
if(n != 0)
|
||||||
r = (w/n < h ? w/n : h)/2;
|
r = (w/n < h ? w/n : h)/2;
|
||||||
|
|
||||||
//génération de la carte
|
//génération de la carte
|
||||||
for (i=0;i<w;i++){
|
for (i=0;i<w;i++){
|
||||||
for(j=0;j<h;j++){
|
for(j=0;j<h;j++){
|
||||||
int d = std::max(w, h);
|
int d = std::max(w, h);
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
d = h;
|
d = h;
|
||||||
for(k=0; k<n; k++){
|
for(k=0; k<n; k++){
|
||||||
d = std::min(d, map.team(k).dist(i, j));
|
d = std::min(d, map.team(k).dist(i, j));
|
||||||
if(!d)
|
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()
|
Map::~Map()
|
||||||
{
|
{
|
||||||
delete m_map;
|
delete[] m_map;
|
||||||
if(m_nbTeams)
|
if(m_nbTeams)
|
||||||
delete m_teams;
|
delete m_teams;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ MapScene::~MapScene()
|
|||||||
glDeleteVertexArrays(1, &m_vao);
|
glDeleteVertexArrays(1, &m_vao);
|
||||||
m_vao = 0;
|
m_vao = 0;
|
||||||
}
|
}
|
||||||
delete m_teamColors;
|
delete[] m_teamColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapScene::updatePixel(const Coord &c)
|
void MapScene::updatePixel(const Coord &c)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
struct MapScene : public Map, public BasicScene
|
struct MapScene : public Map, public BasicScene
|
||||||
{
|
{
|
||||||
public:
|
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();
|
~MapScene();
|
||||||
|
|
||||||
|
@ -210,8 +210,6 @@ void Simulation::handleAction(const Action &action, Dude *dude)
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
target.writeBook(action.com_data);
|
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);
|
dude->setSuccess(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user