<commit_before>#include	"World.hh"

World::World()
{
  _initWorld();
  _initWildBattles();
}

World::~World()
{
}

void		World::_initWorld()
{
  int		banki = 0;
  uint32_t	*bankptr = (uint32_t *) (rom + BANK_PTR);
  uint32_t	rel = bankptr[banki];
  uint32_t	next = bankptr[banki + 1];

  while (next > ROM_OFFSET)
    {
      _banks.push_back(std::vector<Map>());
      std::vector<Map>	&maps = _banks.back();

      for (uint32_t mapi = rel; mapi < next; mapi += 4)
	{
	  maps.push_back(Map());
	  Map		&map = maps.back();
	  uint32_t	mapaddr = *((uint32_t *) gbaMem(mapi));
	  Header	*header = (Header *) gbaMem(mapaddr);
	  DataHeader	*dheader = (DataHeader *) gbaMem(header->mapPtr);
	  TilesetHeader	*global = (TilesetHeader *) gbaMem(dheader->globalTileset);
	  TilesetHeader	*local = (TilesetHeader *) gbaMem(dheader->localTileset);
	  Map::TileAttr	*globPtr = (Map::TileAttr *) gbaMem(global->behaviorPtr);
	  Map::TileAttr	*localPtr = (Map::TileAttr *) gbaMem(local->behaviorPtr);
	  uint16_t	*d = (uint16_t *) gbaMem(dheader->data);
	  Event		*evtPtr = (Event *) gbaMem(header->evtPtr);

	  map.width = dheader->width;
	  map.height = dheader->height;
	  map.nbPersons = evtPtr->nbPersons;
	  map.nbWarps = evtPtr->nbWarps;
	  map.nbScripts = evtPtr->nbScripts;
	  map.nbSigns = evtPtr->nbSigns;
	  map.persons = (PersonEvt *) gbaMem(evtPtr->personsPtr);
	  map.warps = (WarpEvt *) gbaMem(evtPtr->warpsPtr);
	  map.scripts = (ScriptEvt *) gbaMem(evtPtr->scriptsPtr);
	  map.signs = (SignEvt *) gbaMem(evtPtr->signsPtr);
	  map.nbConnects = ((uint32_t *) gbaMem(header->connectPtr))[0];
	  map.connects = (Connection *) gbaMem(((uint32_t *) gbaMem(header->connectPtr))[1]);
	  map.scriptPtr = header->scriptPtr;
	  map.data = new Map::Node*[map.height]();
          map.loadName(header->labelId);
	  for (uint16_t y = 0; y < map.height; y++)
	    {
	      map.data[y] = new Map::Node[map.width]();
	      for (uint16_t x = 0; x < map.width; x++)<commit_msg>fix: # of connections over/underflow<commit_after>#include	"World.hh"

World::World()
{
  _initWorld();
  _initWildBattles();
}

World::~World()
{
}

void		World::_initWorld()
{
  int		banki = 0;
  uint32_t	*bankptr = (uint32_t *) (rom + BANK_PTR);
  uint32_t	rel = bankptr[banki];
  uint32_t	next = bankptr[banki + 1];

  while (next > ROM_OFFSET)
    {
      _banks.push_back(std::vector<Map>());
      std::vector<Map>	&maps = _banks.back();

      for (uint32_t mapi = rel; mapi < next; mapi += 4)
	{
	  maps.push_back(Map());
	  Map		&map = maps.back();
	  uint32_t	mapaddr = *((uint32_t *) gbaMem(mapi));
	  Header	*header = (Header *) gbaMem(mapaddr);
	  DataHeader	*dheader = (DataHeader *) gbaMem(header->mapPtr);
	  TilesetHeader	*global = (TilesetHeader *) gbaMem(dheader->globalTileset);
	  TilesetHeader	*local = (TilesetHeader *) gbaMem(dheader->localTileset);
	  Map::TileAttr	*globPtr = (Map::TileAttr *) gbaMem(global->behaviorPtr);
	  Map::TileAttr	*localPtr = (Map::TileAttr *) gbaMem(local->behaviorPtr);
	  uint16_t	*d = (uint16_t *) gbaMem(dheader->data);
	  Event		*evtPtr = (Event *) gbaMem(header->evtPtr);

	  map.width = dheader->width;
	  map.height = dheader->height;
	  map.nbPersons = evtPtr->nbPersons;
	  map.nbWarps = evtPtr->nbWarps;
	  map.nbScripts = evtPtr->nbScripts;
	  map.nbSigns = evtPtr->nbSigns;
	  map.persons = (PersonEvt *) gbaMem(evtPtr->personsPtr);
	  map.warps = (WarpEvt *) gbaMem(evtPtr->warpsPtr);
	  map.scripts = (ScriptEvt *) gbaMem(evtPtr->scriptsPtr);
	  map.signs = (SignEvt *) gbaMem(evtPtr->signsPtr);
	  map.nbConnects = ((uint32_t *) gbaMem(header->connectPtr))[0];
          if (map.nbConnects > 5)
            map.nbConnects = 0;
	  map.connects = (Connection *) gbaMem(((uint32_t *) gbaMem(header->connectPtr))[1]);
	  map.scriptPtr = header->scriptPtr;
	  map.data = new Map::Node*[map.height]();
          map.loadName(header->labelId);
	  for (uint16_t y = 0; y < map.height; y++)
	    {
	      map.data[y] = new Map::Node[map.width]();
	      for (uint16_t x = 0; x < map.width; x++)
{'fraction_non_alphanumeric': 0.1755782143745337, 'fraction_numerical': 0.01691121611539418, 'mean_word_length': 3.8516284680337756, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3555565', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1602, 'n_words': 271}