Exemple #1
0
//Thread function for saving players
void __cdecl SavePlayerThread(void *arg)
{
	edict_t *ent = (edict_t *)arg;

	if(debuginfo->value)
		gi.dprintf(va("Threading SavePlayerThread() for %s.\n", ent->client->pers.netname));

	if(SavePlayer(ent))
		ent->threadReturnVal = 0;		//success
	else	ent->threadReturnVal = -1;	//failure

	ent->hThreadFinishTime = level.time;
}
Exemple #2
0
qboolean savePlayer(edict_t *ent)
{
	if(gds->value)
	{
		//Don't create more than one save thread.
		if(!ent->isSaving)
			createSavePlayerThread(ent);

		return true;
	}
	
	return SavePlayer(ent);
}
TSharedRef<FJsonObject> UFlareSaveWriter::SaveGame(UFlareSaveGame* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	// General stuff
	JsonObject->SetStringField("Game", "Helium Rain");
	JsonObject->SetStringField("SaveFormat", FormatInt32(1));

	// Game data
	JsonObject->SetObjectField("Player", SavePlayer(&Data->PlayerData));
	JsonObject->SetObjectField("PlayerCompanyDescription", SaveCompanyDescription(&Data->PlayerCompanyDescription));
	JsonObject->SetStringField("CurrentImmatriculationIndex", FormatInt32(Data->CurrentImmatriculationIndex));
	JsonObject->SetObjectField("World", SaveWorld(&Data->WorldData));

	return JsonObject;
}
Exemple #4
0
int CMapFileIO::SaveMap(const CLevelMap &map, HANDLE hFile) const
{
	XML_MANAGER_HANDLE xml = 0;
	std::wostringstream os;
	xml = CreateWorker();
	if(!xml)
		return 1;
	BeginDoc(xml, L"map");
	XML_NODE_HANDLE root = GetRootNode(xml);
	if(!root)
		return 1;
	XML_NODE_HANDLE node;

	int w, h;
	D3DXVECTOR3 pos;

	//dimensions
	node = AddNode(xml, root, L"dimensions");
	if(!node)
		return 1;
	w = map.GetWidth();
	h = map.GetHeight();
	os << w;
	SetNodeAttr(xml, node, L"width", os.str().c_str());
	os.str(L"");
	os << h;
	SetNodeAttr(xml, node, L"height", os.str().c_str());
	os.str(L"");
	ReleaseNode(node);

	//background
	SaveBackground(*map.GetBackground(), xml, root);

	//player
	SavePlayer( map.GetPlayer(), xml, root );

	//tiles
	SaveTileList(map.m_pTiles, xml, root);

	//creatures
	SaveCreatureList(map.m_pCreatures, xml, root);

	SaveToFileHandle(xml, hFile, true);
	CloseHandle(hFile);
	ReleaseWorker(xml);
	return 0;
}
void __cdecl SaveGame()
{
	int v0; // eax
	signed int v1; // ebx
	signed int v2; // esi
	int v3; // esi
	int v4; // esi
	int *v5; // esi
	int *v6; // esi
	int i; // esi
	int *v8; // esi
	int *v9; // esi
	int j; // esi
	int *v11; // esi
	int *v12; // esi
	int k; // esi
	signed int v14; // esi
	int l; // esi
	int m; // esi
	int *v17; // esi
	int *v18; // esi
	int n; // esi
	int *v20; // esi
	char *v21; // edi
	signed int v22; // ebx
	_BYTE *v23; // edi
	signed int v24; // ebx
	char *v25; // edi
	signed int v26; // ebx
	char *v27; // edi
	int (*v28)[112]; // ebx
	int *v29; // edi
	signed int v30; // ebx
	char *v31; // edi
	signed int v32; // ebx
	char *v33; // edi
	signed int v34; // ebx
	char *v35; // edi
	signed int v36; // ebx
	char *v37; // edi
	signed int v38; // ebx
	unsigned char *v39; // edi
	signed int v40; // ebx
	char *v41; // edi
	int v42; // esi
	void *v43; // esi
	int v44; // eax
	char v45[260]; // [esp+Ch] [ebp-10Ch]
	void *ptr; // [esp+110h] [ebp-8h]
	int v47; // [esp+114h] [ebp-4h]

	v0 = codec_get_encoded_len(262147); /* FILEBUFF */
	ptr = DiabloAllocPtr(v0);
	tbuff = ptr;
	ISave_2('RETL');
	OSave(setlevel);
	ISave((unsigned char)setlvlnum);
	ISave(currlevel);
	ISave((unsigned char)leveltype);
	ISave(ViewX);
	ISave(ViewY);
	OSave(invflag);
	OSave(chrflag);
	ISave(nummonsters);
	ISave(numitems);
	ISave(nummissiles);
	ISave(nobjects);
	v1 = 0;
	v2 = 0;
	do
	{
		ISave_2(glSeedTbl[v2]);
		ISave(gnLevelTypeTbl[v2]);
		++v2;
	}
	while ( v2 < 17 );
	SavePlayer(myplr);
	v3 = 0;
	do
		SaveQuest(v3++);
	while ( v3 < 16 );
	v4 = 0;
	do
		SavePortal(v4++);
	while ( v4 < 4 );
	v5 = monstkills;
	do
	{
		ISave_2(*v5);
		++v5;
	}
	while ( (signed int)v5 < (signed int)&monstkills[200] );
	if ( leveltype )
	{
		v6 = monstactive;
		do
		{
			ISave(*v6);
			++v6;
		}
		while ( (signed int)v6 < (signed int)&monstactive[200] );
		for ( i = 0; i < nummonsters; ++i )
			SaveMonster(monstactive[i]);
		v8 = missileactive;
		do
		{
			BSave(*(_BYTE *)v8);
			++v8;
		}
		while ( (signed int)v8 < (signed int)&missileactive[125] );
		v9 = missileavail;
		do
		{
			BSave(*(_BYTE *)v9);
			++v9;
		}
		while ( (signed int)v9 < (signed int)&missileavail[125] );
		for ( j = 0; j < nummissiles; ++j )
			SaveMissile(missileactive[j]);
		v11 = objectactive;
		do
		{
			BSave(*(_BYTE *)v11);
			++v11;
		}
		while ( (signed int)v11 < (signed int)&objectactive[127] );
		v12 = objectavail;
		do
		{
			BSave(*(_BYTE *)v12);
			++v12;
		}
		while ( (signed int)v12 < (signed int)&objectavail[127] );
		for ( k = 0; k < nobjects; ++k )
			SaveObject(objectactive[k]);
		ISave(numlights);
		v14 = 0;
		do
			BSave(lightactive[v14++]);
		while ( v14 < 32 );
		for ( l = 0; l < numlights; ++l )
			SaveLighting((unsigned char)lightactive[l]);
		ISave(visionid);
		ISave(numvision);
		for ( m = 0; m < numvision; ++m )
			SaveVision(m);
	}
	v17 = itemactive;
	do
	{
		BSave(*(_BYTE *)v17);
		++v17;
	}
	while ( (signed int)v17 < (signed int)&itemactive[127] );
	v18 = itemavail;
	do
	{
		BSave(*(_BYTE *)v18);
		++v18;
	}
	while ( (signed int)v18 < (signed int)&itemavail[127] );
	for ( n = 0; n < numitems; ++n )
		SaveItem(itemactive[n]);
	v20 = UniqueItemFlag;
	do
	{
		OSave(*v20);
		++v20;
	}
	while ( (signed int)v20 < (signed int)&UniqueItemFlag[128] );
	do
	{
		v21 = (char *)dTransVal + v1;
		v47 = 112;
		do
		{
			BSave(*v21);
			v21 += 112;
			--v47;
		}
		while ( v47 );
		++v1;
	}
	while ( v1 < 112 );
	v22 = 0;
	do
	{
		v23 = (unsigned char *)dFlags + v22;
		v47 = 112;
		do
		{
			BSave(*v23 & 0xF8);
			v23 += 112;
			--v47;
		}
		while ( v47 );
		++v22;
	}
	while ( v22 < 112 );
	v24 = 0;
	do
	{
		v25 = (char *)dPlayer + v24;
		v47 = 112;
		do
		{
			BSave(*v25);
			v25 += 112;
			--v47;
		}
		while ( v47 );
		++v24;
	}
	while ( v24 < 112 );
	v26 = 0;
	do
	{
		v27 = (char *)dItem + v26;
		v47 = 112;
		do
		{
			BSave(*v27);
			v27 += 112;
			--v47;
		}
		while ( v47 );
		++v26;
	}
	while ( v26 < 112 );
	if ( leveltype )
	{
		v28 = dMonster;
		do
		{
			v29 = (int *)v28;
			v47 = 112;
			do
			{
				ISave(*v29);
				v29 += 112;
				--v47;
			}
			while ( v47 );
			v28 = (int (*)[112])((char *)v28 + 4);
		}
		while ( (signed int)v28 < (signed int)dMonster[1] );
		v30 = 0;
		do
		{
			v31 = (char *)dDead + v30;
			v47 = 112;
			do
			{
				BSave(*v31);
				v31 += 112;
				--v47;
			}
			while ( v47 );
			++v30;
		}
		while ( v30 < 112 );
		v32 = 0;
		do
		{
			v33 = (char *)dObject + v32;
			v47 = 112;
			do
			{
				BSave(*v33);
				v33 += 112;
				--v47;
			}
			while ( v47 );
			++v32;
		}
		while ( v32 < 112 );
		v34 = 0;
		do
		{
			v35 = (char *)dTransVal + v34;
			v47 = 112;
			do
			{
				BSave(*v35);
				v35 += 112;
				--v47;
			}
			while ( v47 );
			++v34;
		}
		while ( v34 < 112 );
		v36 = 0;
		do
		{
			v37 = (char *)dTransVal2 + v36;
			v47 = 112;
			do
			{
				BSave(*v37);
				v37 += 112;
				--v47;
			}
			while ( v47 );
			++v36;
		}
		while ( v36 < 112 );
		v38 = 0;
		do
		{
			v39 = (unsigned char *)automapview + v38;
			v47 = 40;
			do
			{
				OSave(*v39);
				v39 += 40;
				--v47;
			}
			while ( v47 );
			++v38;
		}
		while ( v38 < 40 );
		v40 = 0;
		do
		{
			v41 = (char *)dMissile + v40;
			v47 = 112;
			do
			{
				BSave(*v41);
				v41 += 112;
				--v47;
			}
			while ( v47 );
			++v40;
		}
		while ( v40 < 112 );
	}
	ISave(numpremium);
	ISave(premiumlevel);
	v42 = 0;
	do
		SavePremium(v42++);
	while ( v42 < 6 );
	OSave(automapflag);
	ISave(AutoMapScale);
	pfile_get_game_name(v45);
	v43 = ptr;
	v44 = codec_get_encoded_len((_BYTE *)tbuff - (_BYTE *)ptr);
	pfile_write_save_file(v45, v43, (_BYTE *)tbuff - (_BYTE *)v43, v44);
	mem_free_dbg(v43);
	*(_DWORD *)&gbValidSaveFile = 1;
	pfile_rename_temp_to_perm();
	pfile_write_hero();
}
Exemple #6
0
void Game::SaveGame() {
    SavePlayer();
}
void Interface::MainGame()
{
	string input = "";
	vector<string> parsedInput;
	bool quitGame = false;
	Look();
	cout << "Type 'help' (no ' marks) for a short explanation of basic commands." << endl;
	cout << "Make sure to use the 'growth' command before gaining experience!" << endl;
	while(!quitGame)
	{
		Prompt();
		getline(cin, input);
		for (int i = 0; i < input.size(); i++)
			input[i] = tolower(input[i]);
		parsedInput = ParseInput(input);
		command cmd = CommandControl::GetInstance()->GetCommand(parsedInput.front());
		string target = parsedInput.back();
		if (cmd == LOOK)
			Look();
		if (cmd == GO_NORTH)
			North();
		if (cmd == GO_SOUTH)
			South();
		if (cmd == GO_EAST)
			East();
		if (cmd == GO_WEST)
			West();
		if (cmd == GO_DOWN)
			Down();
		if (cmd == GO_UP)
			Up();
		if (cmd == KILL)
			Kill(parsedInput.back());
		if (cmd == SCORE)
			Score();
		if (cmd == ABILITIES)
			Abilities();
		if (cmd == HELP)
			Help();
		if (cmd == GROWTH)
			Growth();
		if (cmd == QUIT)
			Quit();
		if (cmd == INVENTORY)
			Inventory();
		if (cmd == EQUIPMENT)
			Equipment();
		if (cmd == WEAR)
			Wear(parsedInput.back());
		if (cmd == REMOVE)
			Remove(parsedInput.back());
		if (cmd == EXAMINE)
		{	
			command targetCmd = CommandControl::GetInstance()->GetCommand(parsedInput.back());
			if (targetCmd == INVENTORY)
				ExaInv();
			else if (targetCmd == EQUIPMENT)
				ExaEquip();
			else if (targetCmd == LOOK)
				ExaLook();
			else
				cout << "That is not a valid target to examine." << endl;
		}
		if (cmd == GET)
			Get(parsedInput.back());
		if (cmd == DROP)
			Drop(parsedInput.back());
		if (cmd == USE)
			Use(parsedInput.back());
		if (cmd == SAVE)
			SavePlayer();
	}
}
Exemple #8
0
void Game::GameLoop()
{
    sf::Texture HideHack;
    HideHack.loadFromFile("Tiles/Hack.png");
    for(int y=0; y<24; ++y)
    {
        for(int x=0; x<32; ++x)
        {
            HideMapHack[y][x].setTexture(HideHack);
            HideMapHack[y][x].setPosition((float)x*32, (float)y*32);
        }
    }
    while(Window.isOpen()) 
    {
        sf::Event Event;
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::Closed) || ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape)))
            {
                SaveMap(PathToMap);
                SavePlayer();
                return;
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                switch(Move(NORTH))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(0, -1);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                switch(Move(SOUTH))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(0, 1);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right))
            {
                switch(Move(WEST))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(1, 0);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left))
            {
                switch(Move(EAST))
                {
                case 0:
                    break;
                case 1:
                    RandomEncounter();
                    break;
                case 2:
                    Encounter(-1, 0);
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::C))
            {
                CharacterScreen Screen(Player, Window);
                Screen.MainLoop();
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::S))
            {
                SaveMap(PathToMap);
                SavePlayer();
            }
        }
        Window.clear();
        DrawAll();
        Window.display();
    }
}