Esempio n. 1
0
void LFSR::Save(ostream& stream) const
{
	SaveObject(m_Modulus,stream);
	m_Coeff.Save(stream);
	m_InitialState.Save(stream);
	m_State.Save(stream);
}
Esempio n. 2
0
void CEx27bView::OnEditCopy() 
{
	COleDataSource* pSource = SaveObject();
	if(pSource) {
		pSource->SetClipboard(); // OLE deletes data source 
    }
}
Esempio n. 3
0
   bool
   PersistentAlias::SaveObject(shared_ptr<Alias> pAlias)
   {
      String sErrorMessage;

      return SaveObject(pAlias, sErrorMessage);
   }
   bool 
   PersistentTCPIPPort::SaveObject(shared_ptr<TCPIPPort> pObject, String &errorMessage)
   {
      // errorMessage - not supported yet.

      return SaveObject(pObject);
   }
   bool
   PersistentAlias::SaveObject(std::shared_ptr<Alias> pAlias)
   {
      String sErrorMessage;

      return SaveObject(pAlias, sErrorMessage, PersistenceModeNormal);
   }
Esempio n. 6
0
void Heliport::ImportObject(CAirsideImportFile& importFile)
{
	ALTObject::ImportObject(importFile);
	int nOldAirportID = -1;
	importFile.getFile().getInteger(nOldAirportID);
	m_nAptID = importFile.GetAirportNewIndex(nOldAirportID);

	importFile.getFile().getFloat(m_Radius);
	m_Radius = ARCUnit::ConvertLength(m_Radius,ARCUnit::CM,ARCUnit::M);
	importFile.getFile().getInteger(m_nPathID);

	int nPointCount = 0;
	importFile.getFile().getInteger(nPointCount);
	m_path.init(nPointCount);
	CPoint2008 *pPoint =  m_path.getPointList();
	for (int i = 0; i < nPointCount; i++)
	{
		importFile.getFile().getPoint2008(pPoint[i]);
	}

	importFile.getFile().getLine();

	int nOldObjectID = m_nObjID;
	int nNewObjID = SaveObject(m_nAptID);
	importFile.AddObjectIndexMap(nOldObjectID,nNewObjID);
}
   bool
   PersistentSecurityRange::SaveObject(shared_ptr<SecurityRange> pSR)
   {
      String result;

      return SaveObject(pSR, result);
   }
   bool
   PersistentRouteAddress::SaveObject(shared_ptr<RouteAddress> pRA, String &errorMessage)
   {
      // errorMessage not supported yet.

      return SaveObject(pRA);
   }
void
SaveSystem::AddObject(Saveable* pObj)
{
	m_pSM->AddOpenElement(LoadSave::Instance().GetObjectID(pObj->TellName()), EscapeXMLName(pObj->TellName()), "", 0, NULL, "", false, NULL, false);
	SaveObject(pObj, "");
	m_pSM->CloseCurrentElement();
	if(m_pSM->OpenedLastElement())
		m_pSM->CloseCurrentElement();//close the array itself
}
   __int64 
   PersistentFetchAccountUID::AddUID(__int64 iFAID, const String &sValue)
   {
      shared_ptr<FetchAccountUID> newUID = shared_ptr<FetchAccountUID>(new FetchAccountUID(0, iFAID, sValue, Time::GetCurrentDateTime()));

      String message;
      if (!SaveObject(newUID, message))
         return 0;

      return newUID->GetID();
   }
Esempio n. 11
0
bool FileContent::Save(const wxString &filename)
{
    wxFileOutputStream store(filename);
    SaveObject(store);

    if ( store.GetLastError() != wxSTREAM_NO_ERROR )
        return false;

    SetModified(false);
    return true;
}
Esempio n. 12
0
id0_boolean_t	SaveTheGame(BE_FILE_T file)
{
	id0_word_t	i,compressed,expanded;
	objtype	*o;
	memptr	bigbuffer;

	if (BE_Cross_writeInt16LE(file, &FreezeTime) != 2)
	//if (!CA_FarWrite(file,(void id0_far *)&FreezeTime,sizeof(FreezeTime)))
		return(false);

	// (REFKEEN) Writing fields one-by-one in a cross-platform manner
	if (!SaveGameState(file, &gamestate))
	//if (!CA_FarWrite(file,(void id0_far *)&gamestate,sizeof(gamestate)))
		return(false);

	if (BE_Cross_write_boolean_To16LE(file, &EASYMODEON) != 2)
	//if (!CA_FarWrite(file,(void id0_far *)&EASYMODEON,sizeof(EASYMODEON)))
		return(false);

	expanded = mapwidth * mapheight * 2;
	MM_GetPtr (&bigbuffer,expanded);

	for (i = 0;i < 3;i+=2)	// Write planes 0 and 2
	{
//
// leave a word at start of compressed data for compressed length
//
		compressed = (id0_unsigned_t)CA_RLEWCompress ((id0_unsigned_t id0_huge *)mapsegs[i]
			,expanded,((id0_unsigned_t id0_huge *)bigbuffer)+1,RLETAG);

		*(id0_unsigned_t id0_huge *)bigbuffer = compressed;

		if (BE_Cross_writeInt16LEBuffer(file, bigbuffer, compressed+2) != (id0_word_t)(compressed+2))
		//if (!CA_FarWrite(file,(id0_byte_t id0_far *)bigbuffer,compressed+2) )
		{
			MM_FreePtr (&bigbuffer);
			return(false);
		}
	}

	for (o = player;o;o = o->next)
		// (REFKEEN) Writing fields one-by-one in a cross-platform manner
		if (!SaveObject(file, o))
		//if (!CA_FarWrite(file,(void id0_far *)o,sizeof(objtype)))
		{
			MM_FreePtr (&bigbuffer);
			return(false);
		}

	MM_FreePtr (&bigbuffer);

	return(true);
}
void CFunctionCollection::Save(CArchive &ar)
{
  CSLock lock(m_critsec);
  // First write the date
  char nowtime[26] = {0};
  CString s;
  s.Format("##%s##\r\n\r\n", get_time(nowtime)); 
  ar.WriteString(s);
  // DLL  and notes are a bit special "functions",
  // so they get extra treatment.
  SaveObject(ar, LookUp("notes"));
  SaveObject(ar, LookUp("dll"));
  // Then write the standard formula functions...
  // These are functions and symbols, that
  //   * are essential to control the behaviour 
  //	 of (nearly) every poker bot.
  //   * configure some very important constants.
  for (int i=k_autoplayer_function_allin; 
      i<k_number_of_standard_functions; 
      ++i) {
	  SaveObject(ar, LookUp(k_standard_function_names[i]));
  }
  // f$test and f$debug are again special
  SaveObject(ar, LookUp("f$test"));
  SaveObject(ar, LookUp("f$debug"));
  // Handlists
  COHScriptObject *next_object = GetFirst();
  while (next_object != NULL) {
    if (next_object->IsList()) {
      SaveObject(ar, next_object);
    }
    next_object = GetNext();
  }
  // OpenPPL-functions
  for (int i=k_betround_preflop; i<=k_betround_river; ++i) {
    assert(k_OpenPPL_function_names[i] != "");
    SaveObject(ar, LookUp(k_OpenPPL_function_names[i]));
  }
  // User defined functions
  // We already saved the standard-functions
  next_object = GetFirst();
  while (next_object != NULL) {
    if (next_object->IsUserDefinedFunction()) {
      SaveObject(ar, next_object);
    }
    next_object = GetNext();
  }
}
Esempio n. 14
0
/* static */ bool ScriptInstance::SaveObject(HSQUIRRELVM vm, SQInteger index, int max_depth, bool test)
{
	if (max_depth == 0) {
		ScriptLog::Error("Savedata can only be nested to 25 deep. No data saved."); // SQUIRREL_MAX_DEPTH = 25
		return false;
	}

	switch (sq_gettype(vm, index)) {
		case OT_INTEGER: {
			if (!test) {
				_script_sl_byte = SQSL_INT;
				SlObject(NULL, _script_byte);
			}
			SQInteger res;
			sq_getinteger(vm, index, &res);
			if (!test) {
				int value = (int)res;
				SlArray(&value, 1, SLE_INT32);
			}
			return true;
		}

		case OT_STRING: {
			if (!test) {
				_script_sl_byte = SQSL_STRING;
				SlObject(NULL, _script_byte);
			}
			const SQChar *res;
			sq_getstring(vm, index, &res);
			/* @bug if a string longer than 512 characters is given to SQ2OTTD, the
			 *  internal buffer overflows. */
			const char *buf = SQ2OTTD(res);
			size_t len = strlen(buf) + 1;
			if (len >= 255) {
				ScriptLog::Error("Maximum string length is 254 chars. No data saved.");
				return false;
			}
			if (!test) {
				_script_sl_byte = (byte)len;
				SlObject(NULL, _script_byte);
				SlArray(const_cast<char *>(buf), len, SLE_CHAR);
			}
			return true;
		}

		case OT_ARRAY: {
			if (!test) {
				_script_sl_byte = SQSL_ARRAY;
				SlObject(NULL, _script_byte);
			}
			sq_pushnull(vm);
			while (SQ_SUCCEEDED(sq_next(vm, index - 1))) {
				/* Store the value */
				bool res = SaveObject(vm, -1, max_depth - 1, test);
				sq_pop(vm, 2);
				if (!res) {
					sq_pop(vm, 1);
					return false;
				}
			}
			sq_pop(vm, 1);
			if (!test) {
				_script_sl_byte = SQSL_ARRAY_TABLE_END;
				SlObject(NULL, _script_byte);
			}
			return true;
		}

		case OT_TABLE: {
			if (!test) {
				_script_sl_byte = SQSL_TABLE;
				SlObject(NULL, _script_byte);
			}
			sq_pushnull(vm);
			while (SQ_SUCCEEDED(sq_next(vm, index - 1))) {
				/* Store the key + value */
				bool res = SaveObject(vm, -2, max_depth - 1, test) && SaveObject(vm, -1, max_depth - 1, test);
				sq_pop(vm, 2);
				if (!res) {
					sq_pop(vm, 1);
					return false;
				}
			}
			sq_pop(vm, 1);
			if (!test) {
				_script_sl_byte = SQSL_ARRAY_TABLE_END;
				SlObject(NULL, _script_byte);
			}
			return true;
		}

		case OT_BOOL: {
			if (!test) {
				_script_sl_byte = SQSL_BOOL;
				SlObject(NULL, _script_byte);
			}
			SQBool res;
			sq_getbool(vm, index, &res);
			if (!test) {
				_script_sl_byte = res ? 1 : 0;
				SlObject(NULL, _script_byte);
			}
			return true;
		}

		case OT_NULL: {
			if (!test) {
				_script_sl_byte = SQSL_NULL;
				SlObject(NULL, _script_byte);
			}
			return true;
		}

		default:
			ScriptLog::Error("You tried to save an unsupported type. No data saved.");
			return false;
	}
}
 bool 
 PersistentRoute::SaveObject(std::shared_ptr<Route> pRoute)
 {
    String errorMessage;
    return SaveObject(pRoute, errorMessage, PersistenceModeNormal);
 }
Esempio n. 16
0
bool
PersistentAccount::SaveObject(boost::shared_ptr<Account> pAccount, String &sErrorMessage)
{
    return SaveObject(pAccount, sErrorMessage, false);
}
 bool
 PersistentAccount::SaveObject(std::shared_ptr<Account> pAccount, String &sErrorMessage, PersistenceMode mode)
 {
    return SaveObject(pAccount, sErrorMessage, false, mode);
 }
 bool 
 PersistentFetchAccount::SaveObject(shared_ptr<FetchAccount> pFA, String &errorMessage)
 {
    // errorMessage - Not supported yet.
    return SaveObject(pFA);
 }
 bool 
 PersistentSURBLServer::SaveObject(shared_ptr<SURBLServer> pObject, String &errorMessage)
 {
    // errorMessage - not supported yet.
    return SaveObject(pObject);
 }
 bool 
 PersistentBlockedAttachment::SaveObject(shared_ptr<BlockedAttachment> pObject, String &errorMessage)
 {
    // errorMessage -- not supported yet.
    return SaveObject(pObject);
 }
Esempio n. 21
0
 bool 
 PersistentDomainAlias::SaveObject(shared_ptr<DomainAlias> oDA)
 {
    String sErrorMessage;
    return SaveObject(oDA, sErrorMessage);
 }
Esempio n. 22
0
 bool 
 PersistentRoute::SaveObject(shared_ptr<Route> pRoute)
 {
    String errorMessage;
    return SaveObject(pRoute, errorMessage);
 }
Esempio n. 23
0
    static bool GOMove_Command(ChatHandler* handler, const char* args)
    {
        if (!args)
            return false;

        char* ID_t = strtok((char*)args, " ");
        if (!ID_t)
            return false;
        uint32 ID = (uint32)atol(ID_t);

        char* GObjectID_C = strtok(NULL, " ");
        uint32 GObjectID = 0;
        bool isHex = false;
        if (GObjectID_C)
        {
            GObjectID = strtoul(GObjectID_C, NULL, 0); // can take in hex as well as dec
            isHex = (std::string(GObjectID_C).find("0x") != std::string::npos);
        }

        char* ARG_t = strtok(NULL, " ");
        uint32 ARG = 0;
        if (ARG_t)
            ARG = (uint32)atol(ARG_t);

        WorldSession* session = handler->GetSession();
        Player* player = session->GetPlayer();
        uint64 playerGUID = player->GetGUID();

        if (ID < SPAWN) // no args
        {
            if (ID >= DELET && ID <= GOTO) // has target (needs retrieve gameobject)
            {
                GameObject* target = GetObjectByGObjectID(player, GObjectID, isHex);
                if (!target)
                    ChatHandler(player->GetSession()).PSendSysMessage("Object GUID: %u not found. Temp(%u)", GObjectID, isHex ? 1 : 0);
                else
                {
                    float x,y,z,o;
                    target->GetPosition(x,y,z,o);
                    uint32 p = target->GetPhaseMask();
                    switch(ID)
                    {
                    case DELET: DeleteObject(target/*, isHex ? GObjectID : 0*/); SendSelectionInfo(player, GObjectID, isHex, false); break;
                    case X: SpawnObject(player,player->GetPositionX(),y,z,o,p,true,GObjectID, isHex);      break;
                    case Y: SpawnObject(player,x,player->GetPositionY(),z,o,p,true,GObjectID, isHex);      break;
                    case Z: SpawnObject(player,x,y,player->GetPositionZ(),o,p,true,GObjectID, isHex);      break;
                    case O: SpawnObject(player,x,y,z,player->GetOrientation(),p,true,GObjectID, isHex);    break;
                    case GOTO: player->TeleportTo(target->GetMapId(), x,y,z,o);                     break;
                    case RESPAWN: SpawnObject(player,x,y,z,o,p,false,target->GetEntry(), isHex);           break;
                    case GROUND:
                        {
                            float ground = target->GetMap()->GetHeight(target->GetPhaseMask(), x, y, MAX_HEIGHT);
                            if(ground != INVALID_HEIGHT)
                                SpawnObject(player,x,y,ground,o,p,true,GObjectID, isHex);
                        } break;
                    }
                }
            }
            else
            {
                switch(ID)
                {
                case TEST: session->SendAreaTriggerMessage(player->GetName().c_str());      break;
                case FACE: { float piper2 = M_PI/2; float multi = player->GetOrientation()/piper2; float multi_int = floor(multi); float new_ori = (multi-multi_int > 0.5f) ? (multi_int+1)*piper2 : multi_int*piper2; player->SetFacingTo(new_ori); } break;
                case SAVE: SaveObject(player, GObjectID, isHex);                                   break;
                case SELECTNEAR:
                    {
                        GameObject* object = handler->GetNearbyGameObject();
                        object = GetClosestGObjectID(player, object);
                        if (!object)
                            ChatHandler(player->GetSession()).PSendSysMessage("No objects found");
                        else
                        {
                            bool isHex = (object->GetGUIDHigh() != HIGHGUID_GAMEOBJECT);
                            SendSelectionInfo(player, isHex ? object->GetGUIDHigh() : object->GetDBTableGUIDLow() ? object->GetDBTableGUIDLow() : object->GetGUIDLow(), isHex, true);
                            session->SendAreaTriggerMessage("Selected %s", object->GetName().c_str());
                        }
                    } break;
                }
            }
        }
        else if (ARG && ID >= SPAWN)
        {
            if (ID >= NORTH && ID <= PHASE)
            {
                GameObject* target = GetObjectByGObjectID(player, GObjectID, isHex);
                if (!target)
                    ChatHandler(player->GetSession()).PSendSysMessage("Object GUID: %u not found. Temporary: %s", GObjectID, isHex ? "true" : "false");
                else
                {
                    float x,y,z,o;
                    target->GetPosition(x,y,z,o);
                    uint32 p = target->GetPhaseMask();
                    switch(ID)
                    {
                    case NORTH: SpawnObject(player,x+((float)ARG/100),y,z,o,p,true,GObjectID, isHex);                        break;
                    case EAST: SpawnObject(player,x,y-((float)ARG/100),z,o,p,true,GObjectID, isHex);                         break;
                    case SOUTH: SpawnObject(player,x-((float)ARG/100),y,z,o,p,true,GObjectID, isHex);                        break;
                    case WEST: SpawnObject(player,x,y+((float)ARG/100),z,o,p,true,GObjectID, isHex);                         break;
                    case NORTHEAST: SpawnObject(player,x+((float)ARG/100),y-((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case SOUTHEAST: SpawnObject(player,x-((float)ARG/100),y-((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case SOUTHWEST: SpawnObject(player,x-((float)ARG/100),y+((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case NORTHWEST: SpawnObject(player,x+((float)ARG/100),y+((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case UP: SpawnObject(player,x,y,z+((float)ARG/100),o,p,true,GObjectID, isHex);                           break;
                    case DOWN: SpawnObject(player,x,y,z-((float)ARG/100),o,p,true,GObjectID, isHex);                         break;
                    case RIGHT: SpawnObject(player,x,y,z,o-((float)ARG/100),p,true,GObjectID, isHex);                        break;
                    case LEFT: SpawnObject(player,x,y,z,o+((float)ARG/100),p,true,GObjectID, isHex);                         break;
                    case PHASE: SpawnObject(player,x,y,z,o,ARG,true,GObjectID, isHex);                                       break;
                    }
                }
            }
            else
            {
                switch(ID)
                {
                case SPAWN:
                    {
                        if (SpawnObject(player, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),  player->GetOrientation(), player->GetPhaseMaskForSpawn(), false, ARG, false, true))
                            SpawnQue[player->GetGUID()] = ARG;
                    } break;
                case SPAWNSPELL:
                    {
                        SpawnQue[player->GetGUID()] = ARG;
                    } break;
                case SELECTALLNEAR:
                    { 
                        if (ARG > 5000)
                            ARG = 5000;

                        QueryResult result = WorldDatabase.PQuery("SELECT guid, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%u' AND position_x BETWEEN '%f'-'%u' AND '%f'+'%u' AND position_y BETWEEN '%f'-'%u' AND '%f'+'%u' AND position_z BETWEEN '%f'-'%u' AND '%f'+'%u' ORDER BY order_ ASC LIMIT 100",
                            player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetPositionX(), ARG, player->GetPositionX(), ARG, player->GetPositionY(), ARG, player->GetPositionY(), ARG, player->GetPositionZ(), ARG, player->GetPositionZ(), ARG);

                        if (result)
                        {
                            do
                            {
                                Field* fields   = result->Fetch();
                                uint32 guidLow  = fields[0].GetUInt32();

                                if (GameObject* object = GetObjectByGObjectID(player, guidLow, false))
                                    SendSelectionInfo(player, guidLow, false, true);
                            }
                            while (result->NextRow());
                        }
                        for(std::set<uint32>::const_iterator it = GObjects.begin(); it != GObjects.end();)
                        {
                            GameObject* temp = player->GetGameObject(*it);
                            if(!temp)
                            {
                                GObjects.erase(*it++);
                                continue;
                            }
                            if(temp->IsWithinDistInMap(player, ARG))
                                SendSelectionInfo(player, (*it), true, true);
                            ++it;
                        }
                    } break;
                }
            }
        }
        else
            return false;
        return true;
    }
Esempio n. 24
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();
}
 bool
 PersistentIncomingRelay::SaveObject(boost::shared_ptr<IncomingRelay> pSR, String &errorMessage)
 {
    // errorMessage - not supported yet.
    return SaveObject(pSR);
 }
Esempio n. 26
0
LRESULT WINEXPORT WREMainWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    HMENU       menu;
    LRESULT     ret;
    Bool        pass_to_def;
    WREResInfo  *res_info;
    WORD        wp;
    about_info  ai;

    if( WRECleanupStarted && message != WM_CLOSE ) {
        if( message == WM_DESTROY ) {
            PostQuitMessage( 0 );
        }
        return( DefFrameProc( hWnd, WREMDIWin, message, wParam, lParam ) );
    }

    pass_to_def = TRUE;
    ret = FALSE;
    res_info = WREGetCurrentRes();
    menu = WREGetMenuHandle();

    switch( message ) {
    case WM_DESTROYCLIPBOARD:
        WRForgetBitmapName();
        break;

    case WM_INITMENU:
        if( wParam == (WPARAM)GetMenu( hWnd ) ) {
            WRESetCopyMenuItem( hWnd );
            WRESetPasteMenuItem( hWnd );
        }
        break;

    case WM_MENUSELECT:
        WREHandleMenuSelect( wParam, lParam );
        break;

    case WM_MOVE:
        if( IsZoomed( hWnd ) ) {
            WRESetOption( WREOptScreenMax, TRUE );
        } else if( !IsIconic( hWnd ) ) {
            WREUpdateScreenPosOpt();
            WRESetOption( WREOptScreenMax, FALSE );
        }
        break;

    case WM_SIZE:
        if( wParam == SIZE_MAXIMIZED ) {
            WRESetOption( WREOptScreenMax, TRUE );
        } else if( wParam == SIZE_MINIMIZED ) {
            WREHideSessions( FALSE );
            WREIsMinimized = TRUE;
        } else {
            WREUpdateScreenPosOpt();
            WRESetOption( WREOptScreenMax, FALSE );
        }
        if( wParam != SIZE_MINIMIZED && WREIsMinimized ) {
            WREHideSessions( TRUE );
            BringWindowToTop( hWnd );
            WREIsMinimized = FALSE;
        }
        WREResizeWindows();
        pass_to_def = FALSE;
        break;

    case ACCEL_I_HAVE_CLOSED:
        WREEndEditAccelResource( (WAccelHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case ACCEL_PLEASE_SAVEME:
        WRESaveEditAccelResource( (WAccelHandle)lParam );
        pass_to_def = FALSE;
        break;

    case MENU_I_HAVE_CLOSED:
        WREEndEditMenuResource( (WMenuHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case MENU_PLEASE_SAVEME:
        WRESaveEditMenuResource( (WMenuHandle)lParam );
        pass_to_def = FALSE;
        break;

    case STRING_I_HAVE_CLOSED:
        WREEndEditStringResource( (WStringHandle)lParam );
        if( WRENoInterface ) {
            WRERemoveResource( res_info );
        }
        pass_to_def = FALSE;
        break;

    case STRING_PLEASE_SAVEME:
        WRESaveEditStringResource( (WStringHandle)lParam );
        pass_to_def = FALSE;
        break;

    case ACCEL_PLEASE_OPENME:
    case MENU_PLEASE_OPENME:
    case STRING_PLEASE_OPENME:
        ret = pleaseOpenFile( message );
        pass_to_def = FALSE;
        break;

    case WM_COMMAND:
        wp = LOWORD( wParam );
        switch( wp ) {
        case IDM_OPTIONS:
            pass_to_def = FALSE;
            break;

        case IDM_LOAD_SYMBOLS:
            WRELoadResourceSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_EDIT_SYMBOLS:
            WREEditResourceSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE_SYMBOLS:
            WREResourceSaveSymbols( res_info );
            pass_to_def = FALSE;
            break;

        case IDM_NEW:
            WRECreateNewResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_OPEN:
            WREOpenResource( NULL );
            pass_to_def = FALSE;
            break;

        case IDM_SAVE:
            WRESaveResource( res_info, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_SAVEAS:
            WRESaveResource( res_info, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_DELETE:
            WREDeleteCurrResource( FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_PASTE:
            WREPasteResource( hWnd );
            pass_to_def = FALSE;
            break;

        case IDM_CUT:
            WREClipCurrentResource( hWnd, TRUE );
            pass_to_def = FALSE;
            break;

        case IDM_COPY:
            WREClipCurrentResource( hWnd, FALSE );
            pass_to_def = FALSE;
            break;

        case IDM_NEW_CURSOR:
            WRENewImageResource( CursorService, (uint_16)RT_GROUP_CURSOR );
            break;

        case IDM_NEW_BITMAP:
            WRENewImageResource( BitmapService, (uint_16)RT_BITMAP );
            break;

        case IDM_NEW_ICON:
            WRENewImageResource( IconService, (uint_16)RT_GROUP_ICON );
            break;

        case IDM_NEW_DIALOG:
            WRENewDialogResource();
            break;

        case IDM_NEW_FONT:
        case IDM_NEW_RCDATA:
            pass_to_def = FALSE;
            break;

        case IDM_NEW_ACCELERATOR:
            WRENewAccelResource();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_MENU:
            WRENewMenuResource();
            pass_to_def = FALSE;
            break;

        case IDM_NEW_STRING:
            WRENewStringResource();
            pass_to_def = FALSE;
            break;

        case IDM_RES_SAVEAS:
        case IDM_RES_SAVE_INTO:
            if( res_info != NULL ) {
                if( res_info->current_type == (uint_16)RT_STRING ) {
                    SaveMultObjects( wp == IDM_RES_SAVE_INTO );
                } else {
                    SaveObject( wp == IDM_RES_SAVE_INTO );
                }
            }
            pass_to_def = FALSE;
            break;

        case IDM_RES_EDIT:
            WREHandleResEdit();
            pass_to_def = FALSE;
            break;

        case IDM_RES_MEM_FLAGS:
            WREChangeMemFlags();
            pass_to_def = FALSE;
            break;

        case IDM_RES_RENAME:
            WRERenameResource();
            pass_to_def = FALSE;
            break;

        case IDM_MDI_CASCADE:
        case IDM_MDI_TILEV:
        case IDM_MDI_TILEH:
        case IDM_MDI_ARRANGE:
            WREHandleMDIArrangeEvents( wp );
            pass_to_def = FALSE;
            break;

        case IDM_EXIT:
            /* clean up before we exit */
            PostMessage( WREMainWin, WM_CLOSE, 0, 0 );
            break;

        case IDM_SHOW_RIBBON:
            WREShowRibbon( menu );
            pass_to_def = FALSE;
            break;

        case IDM_HELP:
            WREHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_SEARCH:
            WREHelpSearchRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_HELP_ON_HELP:
            WREHelpOnHelpRoutine();
            pass_to_def = FALSE;
            break;

        case IDM_ABOUT:
            ai.owner = hWnd;
            ai.inst = WREInst;
            ai.name = AllocRCString( WRE_ABOUT_NAME );
            ai.version = banner1p2( _RESEDIT_VERSION_ );
            ai.first_cr_year = AllocRCString( WRE_ABOUT_COPYRIGHT_YEAR );
            ai.title = AllocRCString( WRE_ABOUT_TITLE );
            DoAbout( &ai );
            FreeRCString( ai.name );
            FreeRCString( ai.first_cr_year );
            FreeRCString( ai.title );
            pass_to_def = FALSE;
            break;
        }
        break;

    case WM_DESTROY:
        WWinHelp( WREMainWin, "resedt.hlp", HELP_QUIT, 0 );
        PostQuitMessage( 0 );
        break;

    case WRE_FATAL_EXIT:
        WREFatalExit = TRUE;
        WREQueryKillApp( TRUE );
        PostMessage( WREMainWin, WM_CLOSE, 0, 0 );
        break;

    case WM_ENDSESSION:
        if( !wParam ) {
            WREFatalExit = FALSE;
        }
        break;

    case WM_QUERYENDSESSION:
        if( ret = WREQueryKillApp( FALSE ) ) {
            WREFatalExit = TRUE;
        }
        pass_to_def = FALSE;
        break;

    case WM_CLOSE:
        /* clean up before we exit */
        if( WRECleanupStarted ) {
            pass_to_def = FALSE;
            break;
        }
        WRECleanupStarted = TRUE;
        if( !WRECleanup( WREFatalExit ) ) {
            WRECleanupStarted = FALSE;
            pass_to_def = FALSE;
        }
    }

    if( pass_to_def ) {
        ret = DefFrameProc( hWnd, WREMDIWin, message, wParam, lParam );
    }
    return( ret );
}
Esempio n. 27
0
void __cdecl SaveLevel()
{
	int v0; // eax
	int i; // esi
	int j; // esi
	void *v47; // esi
	int v48; // eax
	int v49; // eax
	char v50[260]; // [esp+0h] [ebp-10Ch]
	void *SaveBuff; // [esp+104h] [ebp-8h]

	if ( !currlevel )
		glSeedTbl[0] = GetRndSeed();
	v0 = codec_get_encoded_len(262147); /* FILEBUFF */
	SaveBuff = DiabloAllocPtr(v0);
	tbuff = SaveBuff;
	if ( leveltype )
	{
		for(i = 0; i < 112; i++)
		{
			for(j = 0; j < 112; j++)
			{
				BSave(dDead[j][i]); /* check */
			}
		}
	}
	ISave(nummonsters);
	ISave(numitems);
	ISave(nobjects);

	if ( leveltype )
	{
		for(i = 0; i < 200; i++)
			ISave(monstactive[i]);

		for(i = 0; i < nummonsters; i++)
			SaveMonster(monstactive[i]);

		for(i = 0; i < 127; i++)
			BSave(objectactive[i]);

		for(i = 0; i < 127; i++)
			BSave(objectavail[i]);

		for(i = 0; i < nobjects; i++)
			SaveObject(objectactive[i]);
	}

	for(i = 0; i < 127; i++)
		BSave(itemactive[i]);

	for(i = 0; i < 127; i++)
		BSave(itemavail[i]);

	for(i = 0; i < numitems; i++)
		SaveItem(itemactive[i]);

	for(i = 0; i < 112; i++)
	{
		for(j = 0; j < 112; j++)
		{
			BSave(dFlags[j][i] & 0xF8);
		}
	}

	for(i = 0; i < 112; i++)
	{
		for(j = 0; j < 112; j++)
		{
			BSave(dItem[j][i]);
		}
	}

	if ( leveltype )
	{
		for(i = 0; i < 112; i++)
		{
			for(j = 0; j < 112; j++)
			{
				ISave(dMonster[j][i]);
			}
		}

		for(i = 0; i < 112; i++)
		{
			for(j = 0; j < 112; j++)
			{
				BSave(dObject[j][i]);
			}
		}

		for(i = 0; i < 112; i++)
		{
			for(j = 0; j < 112; j++)
			{
				BSave(dTransVal[j][i]);
			}
		}

		for(i = 0; i < 112; i++)
		{
			for(j = 0; j < 112; j++)
			{
				BSave(dTransVal2[j][i]);
			}
		}

		for(i = 0; i < 40; i++)
		{
			for(j = 0; j < 40; j++)
			{
				OSave(automapview[j][i]);
			}
		}

		for(i = 0; i < 112; i++)
		{
			for(j = 0; j < 112; j++)
			{
				BSave(dMissile[j][i]);
			}
		}
	}
	GetTempLevelNames(v50);
	v47 = SaveBuff;
	v48 = codec_get_encoded_len((_BYTE *)tbuff - (_BYTE *)SaveBuff);
	pfile_write_save_file(v50, v47, (_BYTE *)tbuff - (_BYTE *)v47, v48);
	mem_free_dbg(v47);
	v49 = myplr;
	if ( setlevel )
		plr[v49]._pSLvlVisited[(unsigned char)setlvlnum] = 1;
	else
		plr[v49]._pLvlVisited[currlevel] = 1;
}
 bool
 PersistentRuleCriteria::SaveObject(std::shared_ptr<RuleCriteria> pRuleCriteria, String &errorMessage, PersistenceMode mode)
 {
    // errorMessage - not supported yet.
    return SaveObject(pRuleCriteria);
 }
Esempio n. 29
0
void ScriptInstance::Save()
{
	ScriptObject::ActiveInstance active(this);

	/* Don't save data if the script didn't start yet or if it crashed. */
	if (this->engine == NULL || this->engine->HasScriptCrashed()) {
		SaveEmpty();
		return;
	}

	HSQUIRRELVM vm = this->engine->GetVM();
	if (this->is_save_data_on_stack) {
		_script_sl_byte = 1;
		SlObject(NULL, _script_byte);
		/* Save the data that was just loaded. */
		SaveObject(vm, -1, SQUIRREL_MAX_DEPTH, false);
	} else if (!this->is_started) {
		SaveEmpty();
		return;
	} else if (this->engine->MethodExists(*this->instance, "Save")) {
		HSQOBJECT savedata;
		/* We don't want to be interrupted during the save function. */
		bool backup_allow = ScriptObject::GetAllowDoCommand();
		ScriptObject::SetAllowDoCommand(false);
		try {
			if (!this->engine->CallMethod(*this->instance, "Save", &savedata, MAX_SL_OPS)) {
				/* The script crashed in the Save function. We can't kill
				 * it here, but do so in the next script tick. */
				SaveEmpty();
				this->engine->CrashOccurred();
				return;
			}
		} catch (Script_FatalError e) {
			/* If we don't mark the script as dead here cleaning up the squirrel
			 * stack could throw Script_FatalError again. */
			this->is_dead = true;
			this->engine->ThrowError(e.GetErrorMessage());
			this->engine->ResumeError();
			SaveEmpty();
			/* We can't kill the script here, so mark it as crashed (not dead) and
			 * kill it in the next script tick. */
			this->is_dead = false;
			this->engine->CrashOccurred();
			return;
		}
		ScriptObject::SetAllowDoCommand(backup_allow);

		if (!sq_istable(savedata)) {
			ScriptLog::Error(this->engine->IsSuspended() ? "This script took too long to Save." : "Save function should return a table.");
			SaveEmpty();
			this->engine->CrashOccurred();
			return;
		}
		sq_pushobject(vm, savedata);
		if (SaveObject(vm, -1, SQUIRREL_MAX_DEPTH, true)) {
			_script_sl_byte = 1;
			SlObject(NULL, _script_byte);
			SaveObject(vm, -1, SQUIRREL_MAX_DEPTH, false);
			this->is_save_data_on_stack = true;
		} else {
			SaveEmpty();
			this->engine->CrashOccurred();
		}
	} else {
		ScriptLog::Warning("Save function is not implemented");
		_script_sl_byte = 0;
		SlObject(NULL, _script_byte);
	}
}
 bool
 PersistentDistributionList::SaveObject(std::shared_ptr<DistributionList> pDistList)
 {
    String sErrorMessage;
    return SaveObject(pDistList, sErrorMessage, PersistenceModeNormal);
 }