コード例 #1
0
ファイル: p_saveg.cpp プロジェクト: meiavy/doom-legacy
void GameInfo::LoadGame(int slot)
{
  CONS_Printf("Loading a game...\n");
  char  savename[255];
  byte *savebuffer;

  sprintf(savename, savegamename, slot);

  int length = FIL_ReadFile(savename, &savebuffer);
  if (!length)
    {
      CONS_Printf("Couldn't open save file %s\n", savename);
      return;
    }

  LArchive a;
  if (!a.Open(savebuffer, length))
    return;

  Z_Free(savebuffer); // the compressed buffer is no longer needed

  Downgrade(LEGACY_VERSION); // reset the game version
  SV_Reset();
  ReadResourceLumps();

  // dearchive all the modifications
  if (Unserialize(a))
    {
      CONS_Printf("\aSavegame file corrupted!\n\n");
      SV_Reset();
      return;
    }

  SetState(GS_LEVEL);

  if (netgame)
    net->SV_Open(true); // let the remote players in

  paused = false;

  // view the local human players by default
  for (int i=0; i < NUM_LOCALHUMANS; i++)
    if (LocalPlayers[i].info)
      ViewPlayers.push_back(LocalPlayers[i].info);

  // TODO have other playerinfos waiting for clients to rejoin
  if (ViewPlayers.size())
    hud.ST_Start();
  // done
  /*
  if (setsizeneeded)
    R_ExecuteSetViewSize();

  R_FillBackScreen();  // draw the pattern into the back screen
  */
  con.Toggle(true);
  CONS_Printf("...done.\n");
}
コード例 #2
0
ファイル: movetree.cpp プロジェクト: hokiejer/chessica
int ResetTree::MoveTree(int Depth, int Ply, long long int *NodeCount, int ThreadID)
{
  ResetTree *MyChild, *CurrentNode;
  int OneMove = 0;

//printf("MoveTree(%d,%d,ptr)\n",Depth,Ply);
  //MoveHistory[Ply] = this;
  if (Depth == 0)
  {
    ScoreResetNode();
    //PrintMoveHistory(Ply); PrintReset();
    (*NodeCount)++;
  }
  else
  {
    if (Ply == 0)
    {
      //Ensure that the children are created
      Serialize();
      CurrentNode = NewOrphan(RUNS_SERIALLY); //$$$ hardcoded to zero
      while(GenerateNextMove(CurrentNode))
      {
        PutNodeLastInList(CurrentNode);
        CurrentNode->InitializeSerialization();
        CurrentNode = NewOrphan(RUNS_SERIALLY); //$$$ hardcoded to zero
      }
      CurrentNode->DeleteMe(ThreadID);
      Unserialize(); 

      //Try to serialize a child and work it
      CurrentNode = Children.First;
      while(CurrentNode)
      {
        if (CurrentNode->Serialize_Or_Skip())
        {
          OneMove = Ply+1;	//nonzero - Should be in a register
          CurrentNode->SerialMoveTree(Depth-1,Ply+1,NodeCount);
          //Leave this serialized
        }
        CurrentNode = CurrentNode->NextSibling;
      }
    }
    else //No serialization necessary
    {
      InitializeMoveGeneration();
      MyChild = NewOrphan(RUNS_SERIALLY); //$$$ hardcoded to zero
      while(GenerateNextMove(MyChild))
      {
        OneMove = Depth;	//nonzero - Depth should be in a register
        MyChild->SerialMoveTree(Depth-1,Ply+1,NodeCount);
        InitMyChild(MyChild);
      }
      MyChild->DeleteMe(ThreadID); 
    }
  }
}
コード例 #3
0
ファイル: flag.cpp プロジェクト: master4523/crimsonglory
CFlag::CFlag( const c8* scriptFilename )
{
    Reset();

    factoryName = "flag";

    if ( scriptFilename != "" )
    {
      Load( scriptFilename );
      Unserialize( loadedBitStream );
    }
}
コード例 #4
0
AnimationMaster AnimationMaster::Unserialize(Renderer* renderer,
		std::shared_ptr<PBase::File> file) {

	rapidjson::Document doc;

	PBase::String src = file->ReadFileAsString();

	PBase::Log::LogMessage("AnimationMaster", PBase::String("Loading: ").Append(file->Path()));

	doc.Parse<0>(src.Raw());

	rapidjson::Value val;
	val.Swap(doc);

	return Unserialize(renderer, &val);
}
コード例 #5
0
	ContentsDisplayDialog::ContentsDisplayDialog (QWidget *parent)
	: QDialog (parent)
	, ContentsModel_ (new QStandardItemModel (this))
	{
		Ui_.setupUi (this);
		Ui_.ContentsTree_->setModel (ContentsModel_);

		auto makePair = [] (const QString& leftText, const QString& rightText) -> QList<QStandardItem*>
		{
			QList<QStandardItem*> result;
			result << new QStandardItem (leftText)
				<< new QStandardItem (rightText);
			for (auto item : result)
				item->setEditable (false);
			return result;
		};

		for (auto pluginObj : Core::Instance ().GetStoragePlugins ())
		{
			auto ii = qobject_cast<IInfo*> (pluginObj);
			auto isp = qobject_cast<IStoragePlugin*> (pluginObj);

			auto pluginItems = makePair (ii->GetName (), ii->GetInfo ());

			for (const auto& key : isp->ListKeys ())
			{
				const auto& valList = isp->Load (key);
				const auto& keyPair = makePair (QString::fromUtf8 (key), QString ());
				pluginItems.first ()->appendRow (keyPair);
				int valIndex = 0;
				for (const auto& valVar : valList)
				{
					const auto& str = Unserialize (valVar);
					keyPair.first ()->appendRow (makePair (QString::number (++valIndex), str));
				}
			}

			ContentsModel_->appendRow (pluginItems);
		}

		Ui_.ContentsTree_->expandAll ();
	}
コード例 #6
0
ファイル: Frame.cpp プロジェクト: Faiva78/pioneer
Frame *Frame::Unserialize(Serializer::Reader &rd, Space *space, Frame *parent)
{
	Frame *f = new Frame();
	f->m_parent = parent;
	f->m_flags = rd.Int32();
	f->m_radius = rd.Double();
	f->m_label = rd.String();
	f->m_pos = rd.Vector3d();
	for (int i=0; i<9; i++) f->m_orient[i] = rd.Double();
	f->m_angSpeed = rd.Double();
	f->m_sbody = space->GetSystemBodyByIndex(rd.Int32());
	f->m_astroBodyIndex = rd.Int32();
	f->m_vel = vector3d(0.0);
	for (int i=rd.Int32(); i>0; --i) {
		f->m_children.push_back(Unserialize(rd, space, f));
	}
	Sfx::Unserialize(rd, f);

	f->ClearMovement();
	return f;
}
コード例 #7
0
ファイル: Map.cpp プロジェクト: Reynmar/pocketheroes
bool iMapInfo::ReadMapInfo(iFileI* pFile)
{
	// Map version
	uint16 ver;
	pFile->Read(&ver,sizeof(ver));
	if (ver != GMAP_FILE_VERSION) return false;

	// Save timestamp
	pFile->Read(&m_saveTime, sizeof(m_saveTime));
	
	// Random seed
	pFile->Read(&m_rseed, sizeof(m_rseed));

	// Map size
	uint8 mapSiz; pFile->Read(&mapSiz,sizeof(mapSiz));
	m_Size = (MAP_SIZE)mapSiz;

	// Map name and description (string of text)
	Unserialize(pFile, m_Name);
	Unserialize(pFile, m_Description);

	// Map version and author (string of text)
	Unserialize(pFile, m_Version);
	Unserialize(pFile, m_Author);

	// Current date (1 is default value for new game)
	pFile->Read(&m_curDay, sizeof(m_curDay));

	// Game mode (GM_UNDEFINED for new map)
	uint16 gameMode;
	pFile->Read(&gameMode,sizeof(gameMode));
	m_gameMode = (GameMode)gameMode;

	// Difficulty level (DFC_UNDEFINED for new game)
	sint8 gameDifLvl;
	pFile->Read(&gameDifLvl,sizeof(gameDifLvl));
	m_Difficulty = (DIFFICULTY_LEVEL)gameDifLvl;
	
	// Read Player config
	uint16 pCount;
	pFile->Read(&pCount, sizeof(pCount));
	bool bHumanDefined = false;
	for (uint32 xx=0; xx<pCount; ++xx){
		// Player Id
		sint8 playerId;	
		pFile->Read(&playerId,sizeof(playerId));
		// Nation type
		uint8 nation;
		pFile->Read(&nation,sizeof(nation));
		// Player Type Mask
		uint8 playerTypeMask;
		pFile->Read(&playerTypeMask,sizeof(playerTypeMask));
		// Player Type (PT_UNDEFINED for new game)
		uint8 playerType;
		pFile->Read(&playerType,sizeof(playerType));
		// Create playerInfo descriptor
		iPlayerInfo playerInfo((PLAYER_ID)playerId, (PLAYER_TYPE_MASK)playerTypeMask, (PLAYER_TYPE)playerType, (CTL_TYPE)nation);
		if (playerType == PT_UNDEFINED) {
			if (!bHumanDefined && (playerTypeMask == PTM_HUMAN_ONLY || playerTypeMask == PTM_HUMAN_OR_COMPUTER)) {
				bHumanDefined = true;
				playerInfo.m_Type = PT_HUMAN;
			} else {
				playerInfo.m_Type = PT_COMPUTER;
			}
		}
		// Player resources (undefined for new game)
		Unserialize(pFile, playerInfo.m_Minerals);
		// Current Hero idx (0xFFFF = undefined for new game)
		pFile->Read(&playerInfo.m_curHeroId,sizeof(playerInfo.m_curHeroId));
		// Current Castle idx (0xFFFF = undefined for new game)
		pFile->Read(&playerInfo.m_curCastleIdx,sizeof(playerInfo.m_curCastleIdx));
		// Keys state
		pFile->Read(&playerInfo.m_keys,sizeof(playerInfo.m_keys));
		// Insert Player descriptor
		m_Players.Add(playerInfo);
	}

	// Current player Id (PID_NEUTRAL = undefined for new game)
	uint16 curPlayerId;
	pFile->Read(&curPlayerId,sizeof(curPlayerId));
	if (curPlayerId == 0xFFFF)m_curPlayerId = PID_NEUTRAL;
	else m_curPlayerId = (PLAYER_ID)curPlayerId;

	// Map metrics
	uint16 w,h;
	pFile->Read(&w,sizeof(w));
	pFile->Read(&h,sizeof(h));
	m_metrics.w = w;
	m_metrics.h = h;

	return true;
}
コード例 #8
0
void CMIPSTags::Unserialize(Framework::Xml::CNode* parentNode, const char* sectionName)
{
	auto section = parentNode->Select(sectionName);
	if(!section) return;
	Unserialize(section);
}
コード例 #9
0
ファイル: avtCellList.C プロジェクト: burlen/visit_vtk_7_src
void
avtCellList::ExtractCells(const char * const *msgs, const int *lens, int np,
                          avtVolume *vol)
{
    avtHexahedron            hex;
    avtPoint                 pt;
    avtPyramid               pyr;
    avtTetrahedron           tet;
    avtWedge                 wedge;

    hex.nVars   = nVars;
    pyr.nVars   = nVars;
    pt.nVars    = nVars;
    tet.nVars   = nVars;
    wedge.nVars = nVars;

    int   width  = vol->GetVolumeWidth();
    int   height = vol->GetVolumeHeight();
    int   depth  = vol->GetVolumeDepth();

    avtHexahedronExtractor hexExtractor(width, height, depth, vol, this);
    hexExtractor.SetJittering(jittering);
    avtPointExtractor pointExtractor(width, height, depth, vol, this);
    pointExtractor.SetJittering(jittering);
    avtPyramidExtractor pyrExtractor(width, height, depth, vol, this);
    pyrExtractor.SetJittering(jittering);
    avtTetrahedronExtractor tetExtractor(width, height, depth, vol, this);
    tetExtractor.SetJittering(jittering);
    avtWedgeExtractor wedgeExtractor(width, height, depth, vol, this);
    wedgeExtractor.SetJittering(jittering);

    if (useRestriction)
    {
        hexExtractor.Restrict(minWidth, maxWidth, minHeight, maxHeight);
        pointExtractor.Restrict(minWidth, maxWidth, minHeight, maxHeight);
        pyrExtractor.Restrict(minWidth, maxWidth, minHeight, maxHeight);
        tetExtractor.Restrict(minWidth, maxWidth, minHeight, maxHeight);
        wedgeExtractor.Restrict(minWidth, maxWidth, minHeight, maxHeight);
    }

    for (int i = 0 ; i < np ; i++)
    {
        const char *tmpmsg = msgs[i];
        while (tmpmsg < msgs[i] + lens[i])
        {
            int npts = 0;
            InlineExtract((char *)&npts, tmpmsg, sizeof(int));
           
            switch (npts)
            {
                case 1:
                   UnserializePoint(pt.bbox, pt.val, tmpmsg);
                   pointExtractor.Extract(pt);
                   break;

                case 4:
                   Unserialize(tet.pts, tet.val, 4, tmpmsg);
                   tetExtractor.Extract(tet);
                   break;

                case 5:
                   Unserialize(pyr.pts, pyr.val, 5, tmpmsg);
                   pyrExtractor.Extract(pyr);
                   break;

                case 6:
                   Unserialize(wedge.pts, wedge.val, 6, tmpmsg);
                   wedgeExtractor.Extract(wedge);
                   break;

                case 8:
                   Unserialize(hex.pts, hex.val, 8, tmpmsg);
                   hexExtractor.Extract(hex);
                   break;

                default:
                   EXCEPTION1(InvalidCellTypeException, npts);
            }
        }
    }
}
コード例 #10
0
	{
		std::array<char, 256> datas; // The array must be bigger than any of the serializable classes
		Nz::MemoryView stream(datas.data(), datas.size());

		Nz::SerializationContext context;
		context.stream = &stream;

		WHEN("We serialize basic types")
		{
			THEN("Arithmetical types")
			{
				context.stream->SetCursorPos(0);
				REQUIRE(Serialize(context, 3));
				int value = 0;
				context.stream->SetCursorPos(0);
				REQUIRE(Unserialize(context, &value));
				REQUIRE(value == 3);
			}

			THEN("Boolean type")
			{
				context.stream->SetCursorPos(0);
				REQUIRE(Serialize(context, true));
				context.stream->SetCursorPos(0);
				bool value = false;
				REQUIRE(Unserialize(context, &value));
				REQUIRE(value == true);
			}
		}

		WHEN("We serialize mathematical classes")
コード例 #11
0
ファイル: stats.cpp プロジェクト: glftpd/ebftpd
std::vector< ::stats::Stat> 
RetrieveUsers(const std::string&                    section, 
              ::stats::Timeframe                    timeframe, 
              ::stats::Direction                    direction, 
              boost::optional< ::stats::SortField>  sortField = boost::none, 
              boost::optional<acl::UserID>          uid = boost::none)
{
  static const char* sortFields[] =
  {
    "total kbytes",
    "total files",
    "avg speed"
  };

  mongo::BSONObjBuilder match;
  match.append("direction", util::EnumToString(direction));
  match.appendElements(Serialize(timeframe));
  
  if (!section.empty())
    match.append("section", section);
  else
  {
    mongo::BSONArrayBuilder sections;
    for (const auto& kv : cfg::Get().Sections())
      sections.append(kv.first);
    match.appendElements(BSON("section" << BSON("$in" << sections.arr())));
  }
  
  if (uid) match.append("uid", *uid);
  
  mongo::BSONArrayBuilder ops;
  ops.append(BSON("$match" << match.obj()));
  ops.append(BSON("$group" << BSON("_id" << "$uid" <<
             "total kbytes" << BSON("$sum" << "$kbytes") <<
             "total files" << BSON("$sum" << "$files") <<
             "total xfertime" << BSON("$sum" << "$xfertime"))));
  
  ops.append(BSON("$project" << BSON("total kbytes" << 1 <<
             "total files" << 1 <<
             "total xfertime" << 1 <<
             "avg speed" << BSON("$divide" << 
             BSON_ARRAY("$total kbytes" << "$total xfertime")))));
           
  if (sortField)
  {
    ops.append(BSON("$sort" << BSON(sortFields[static_cast<unsigned>(*sortField)] << -1)));
  }

  auto cmd = BSON("aggregate" << "transfers" << "pipeline" << ops.arr());

  std::vector< ::stats::Stat> users;
  mongo::BSONObj result;
  NoErrorConnection conn;
  if (conn.RunCommand(cmd, result))
  {
    for (const auto& elem : result["result"].Array())
    {
      users.emplace_back(Unserialize(elem.Obj()));
    }
  }
  
  return users;
}
コード例 #12
0
ファイル: XSSkein.cpp プロジェクト: zjucsxxd/wfxs
XSSkein::XSSkein(std::istream &src)
{
    Unserialize(src);
}