Example #1
0
bool CIwMapGame::GetLocation(s3eLocation& location)
{
	uint64 timer = s3eTimerGetMs();

	if (g_lastGpsLookup == 0 || (timer - g_lastGpsLookup) > 500)
	{
		if (S3E_RESULT_SUCCESS != s3eLocationGet(&location))
		{
			return false;
		}
		s3eFilePrintf(g_pFile, "%lld\t%lld\t%4.9f\t%4.9f\t%4.9f\t%4.9f\t%4.9f\r\n", timer, location.m_TimeStampUTC, location.m_Longitude, location.m_Latitude, location.m_Altitude, location.m_HorizontalAccuracy, location.m_VerticalAccuracy);
		s3eFileFlush(g_pFile);

		if (g_bTrackingDistance)
		{
			g_distanceTravelled += LiveMaps::CalculateDistance(g_lastLocation, location);
		}

		g_lastLocation = location;
		g_lastGpsLookup = timer;
		return true;
	}
	else
	{
		if (g_lastGpsLookup)
		{
			location = g_lastLocation;
			return true;
		}
		return false;
	}
}
Example #2
0
void MapBackground::SaveMapTileImage(MapTile* pTile, void* gResult, uint32 gResultLen, bool isJpg)
{
	char szImage[200], szPath[200];
	strcpy(szImage, pTile->szImageUrl);

	char* szName = strrchr(szImage, '/')+1;
	strchr(szName, '.')[0] = 0;

	strcpy(szPath, "tiles/");
	strcat(szPath, szName);

	if (isJpg)
	{
		strcat(szPath, ".jpg");
	}
	else
	{
		strcat(szPath, ".png");
	}

	s3eFile* pFile = s3eFileOpen(szPath, "w");

	if (pFile)
	{
		uint32 x = s3eFileWrite(gResult, 1, gResultLen, pFile);
		s3eFileFlush(pFile);
		s3eFileClose(pFile);
	}
}
Example #3
0
void Map::ReadJsonFile(char * filename)
{
	cJSON *root;
	char * jsonContent;
	s3eFile* fileHandler;
	fileHandler=s3eFileOpen(filename, "rb");
	if (fileHandler != NULL)
    {
        // Allocate buffer to be filled with the files contents
        int32 fileSize = s3eFileGetSize(fileHandler);
        jsonContent = (char*)s3eMallocBase(fileSize+1);

        // Read data from file
        if (s3eFileRead(&jsonContent[0], fileSize+1, 1, fileHandler) != 1)
        {
            // An kError has occurred, retrieve information for display
			std::cout<<s3eFileGetErrorString()<<std::endl;
        }
        else
        {
            // Data reading has been successful
            jsonContent[fileSize] = '\0';
        }
    }
    else
    {
        // Something went wrong during opening of the file retrieve error for display
		std::cout<<s3eFileGetErrorString()<<std::endl;
    }
	if (fileHandler)
		s3eFileClose(fileHandler);
	root = cJSON_Parse(jsonContent);
	s3eFileFlush(fileHandler);

	_height=cJSON_GetObjectItem(root,"height")->valueint;
	cJSON *layers = cJSON_GetObjectItem(root,"layers");
	_tileHeight=cJSON_GetObjectItem(root,"tileheight")->valueint;
	_tileWidth=cJSON_GetObjectItem(root,"tilewidth")->valueint;
	_width=cJSON_GetObjectItem(root,"width")->valueint;
	_layer_base->Init(cJSON_GetArrayItem(layers,0));
	_layer_middle->Init(cJSON_GetArrayItem(layers,1));
	_layer_maze->Init(cJSON_GetArrayItem(layers,2));
	cJSON *tilesets = cJSON_GetObjectItem(root,"tilesets");
	_tileset_map->Init(cJSON_GetArrayItem(tilesets,0));
	_tileset_maze->Init(cJSON_GetArrayItem(tilesets,1));

	

	_total=_height*_width;
	_size=CIwSVec2(_width*_tileWidth,_height*_tileHeight);

}
Example #4
0
CIwMapGame::~CIwMapGame()
{
	std::list<GameStatePair*>::iterator iter = g_gameStates.begin();

	while (iter != g_gameStates.end())
	{
		GameStatePair* pPair = *iter;
		delete pPair->pGameState;
		delete pPair;
		iter++;
	}
	s3eFileFlush(g_pFile);
	s3eFileClose(g_pFile);
}
Example #5
0
AKRESULT s3eIOHook::Write(AkFileDesc &in_fileDesc, const AkIoHeuristics &, void *in_pData, AkIOTransferInfo &io_transferInfo)
{
	int32 position = (int32)io_transferInfo.uFilePosition;

	if( s3eFileSeek((s3eFile *)in_fileDesc.hFile, position, S3E_FILESEEK_SET) == S3E_RESULT_SUCCESS )
	{
		uint32 itemsWritten = s3eFileWrite( in_pData, 1, io_transferInfo.uRequestedSize, (s3eFile *)in_fileDesc.hFile );
		if( itemsWritten > 0 )
		{
			s3eFileFlush( (s3eFile *)in_fileDesc.hFile );
			return AK_Success;
		}
	}
	return AK_Fail;
}
Example #6
0
void Map::ReadJsonFile(char * filename)
{
	m_filename=filename;
	cJSON *root;
	char * jsonContent;
	s3eFile* fileHandler;
	fileHandler=s3eFileOpen(filename, "rb");
	if (fileHandler != NULL)
    {
        // Allocate buffer to be filled with the files contents
        int32 fileSize = s3eFileGetSize(fileHandler);
        jsonContent = (char*)s3eMallocBase(fileSize+1);

        // Read data from file
        if (s3eFileRead(&jsonContent[0], fileSize+1, 1, fileHandler) != 1)
        {
            // An kError has occurred, retrieve information for display
			std::cout<<s3eFileGetErrorString()<<std::endl;
        }
        else
        {
            // Data reading has been successful
            jsonContent[fileSize] = '\0';
        }
    }
    else
    {
        // Something went wrong during opening of the file retrieve error for display
		std::cout<<s3eFileGetErrorString()<<std::endl;
    }
	if (fileHandler)
		s3eFileClose(fileHandler);
	root = cJSON_Parse(jsonContent);
	s3eFileFlush(fileHandler);

	_height=cJSON_GetObjectItem(root,"height")->valueint;
	cJSON *layers = cJSON_GetObjectItem(root,"layers");
	_tileHeight=cJSON_GetObjectItem(root,"tileheight")->valueint;
	_tileWidth=cJSON_GetObjectItem(root,"tilewidth")->valueint;
	_width=cJSON_GetObjectItem(root,"width")->valueint;
	_layer_base->Init(cJSON_GetArrayItem(layers,0));
	_layer_middle->Init(cJSON_GetArrayItem(layers,1));
	_layer_maze->Init(cJSON_GetArrayItem(layers,2));
	cJSON *tilesets = cJSON_GetObjectItem(root,"tilesets");
	_tileset_map->Init(cJSON_GetArrayItem(tilesets,0));
	_tileset_maze->Init(cJSON_GetArrayItem(tilesets,1));

	cJSON * properties=cJSON_GetObjectItem(root,"properties");
	int propSize=cJSON_GetArraySize(properties);
	for(int i=propSize-1;i!=-1;i--)
	{
		cJSON * prop=cJSON_GetArrayItem(properties,i);
		char* propString=prop->valuestring;

		char* name=prop->string;

		char* chars_array = strtok(propString, ",");
		if(CharCMP(name,"Block",sizeof("Block")))
		{
			while(chars_array)
			{
				_EventBlock.append(atoi(chars_array));
				chars_array = strtok(NULL, ",");
			}
		}
		else if(CharCMP(name,"BG",sizeof("BG")))
		{
			_BGImage=Iw2DCreateImageResource(propString);
		}
		else if(CharCMP(name,"Door",sizeof("Door")))
		{
			while(chars_array)
			{
				m_doors.append(atoi(chars_array));
				chars_array = strtok(NULL, ",");
			}
		}
		else if(CharCMP(name,"EndPoint",sizeof("EndPoint")))
		{
			_EndPos[0]=atoi(chars_array);
			chars_array = strtok(NULL, ",");
			_EndPos[1]=atoi(chars_array);
		}
		else if(CharCMP(name,"StartPoint",sizeof("StartPoint")))
		{
			_StartPos[0]=atoi(chars_array);
			chars_array = strtok(NULL, ",");
			_StartPos[1]=atoi(chars_array);
		}
		else if(CharCMP(name,"emaze",sizeof("emaze")))
		{
			while(chars_array)
			{
				mapEndIndex.append(atoi(chars_array));
				chars_array = strtok(NULL, ",");
			}
		}
		else if(CharCMP(name,"etmaze",sizeof("etmaze")))
		{
			while(chars_array)
			{
				mazeEndIndex.append(atoi(chars_array));
				chars_array = strtok(NULL, ",");
			}
		}
		else if(CharCMP(name,"smaze",sizeof("smaze")))
		{
			while(chars_array)
			{
				mapStartIndex.append(atoi(chars_array));
				chars_array = strtok(NULL, ",");
			}
		}
		else if(CharCMP(name,"stmaze",sizeof("stmaze")))
		{
			while(chars_array)
			{
				mazeStartIndex.append(atoi(chars_array));
				chars_array = strtok(NULL, ",");
			}
		}
	}

	_total=_height*_width;
	_size=CIwSVec2(_width*_tileWidth,_height*_tileHeight);

}