Ejemplo n.º 1
0
void ConstructionTask::giveUnit(Unit unit)
{
	if(unit->getType() == mType.whatBuilds().first)
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Given Builder");
		assert(!mBuilder);
		mBuilder = unit;
		reserveResources();
	}
	else if(unit == mReservedLocation->getUnitPrediction() || unit->getTilePosition() == mReservedLocation->getTilePosition())
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Given Produced Unit");

		assert(!mProducedUnit || !mProducedUnit->exists());

		mProducedUnit = unit;
		if(mProducedUnit->exists())
		{
			freeResources();
			freeLocation();
		}
	}
	else
		assert(false);
}
Ejemplo n.º 2
0
void CJoystick::Initialise()
{
	bool joystickEnable = false;
	CFG_GET_USER_VAL("joystick.enable", Bool, joystickEnable);
	if (!joystickEnable)
		return;

	CFG_GET_USER_VAL("joystick.deadzone", Int, m_Deadzone);

	if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
	{
		LOGERROR(L"InitInput: failed to initialise joystick");
		return;
	}

	int numJoysticks = SDL_NumJoysticks();

	LOGMESSAGE(L"Found %d joystick(s)", numJoysticks);

	for (int i = 0; i < numJoysticks; ++i)
		LOGMESSAGE(L"Joystick %d: %hs", i, SDL_JoystickName(i));

	if (numJoysticks)
	{
		SDL_JoystickEventState(SDL_ENABLE);

		// Always pick the first joystick, and assume that's the right one
		m_Joystick = SDL_JoystickOpen(0);
	}
}
Ejemplo n.º 3
0
void CNetClientSession::Poll()
{
	PROFILE3("net client poll");

	ENSURE(m_Host && m_Server);

	m_FileTransferer.Poll();

	ENetEvent event;
	while (enet_host_service(m_Host, &event, 0) > 0)
	{
		switch (event.type)
		{
		case ENET_EVENT_TYPE_CONNECT:
		{
			ENSURE(event.peer == m_Server);

			// Report the server address
			char hostname[256] = "(error)";
			enet_address_get_host_ip(&event.peer->address, hostname, ARRAY_SIZE(hostname));
			LOGMESSAGE("Net client: Connected to %s:%u", hostname, (unsigned int)event.peer->address.port);

			m_Client.HandleConnect();

			break;
		}

		case ENET_EVENT_TYPE_DISCONNECT:
		{
			ENSURE(event.peer == m_Server);

			LOGMESSAGE("Net client: Disconnected");
			m_Client.HandleDisconnect(event.data);
			return;
		}

		case ENET_EVENT_TYPE_RECEIVE:
		{
			CNetMessage* msg = CNetMessageFactory::CreateMessage(event.packet->data, event.packet->dataLength, m_Client.GetScriptInterface());
			if (msg)
			{
				LOGMESSAGE("Net client: Received message %s of size %lu from server", msg->ToString().c_str(), (unsigned long)msg->GetSerializedLength());

				m_Client.HandleMessage(msg);

				delete msg;
			}

			enet_packet_destroy(event.packet);

			break;
		}

		case ENET_EVENT_TYPE_NONE:
			break;
		}
	}

}
Ejemplo n.º 4
0
bool ConstructionTask::update()
{
	if(mBuilder)
	{
		if(shouldReturnUnit())
		{
			if(!mBuilder->cancel())
				mBuilder->stop();
		}
		else
		{
			if(!mProducedUnit || !mProducedUnit->exists())
			{
				if(mReservedLocation && mReservedLocation->isCalculated())
					mBuilder->build(mReservedLocation->getTilePosition(), mType);
			}
			else if(mType.getRace() == BWAPI::Races::Terran && (!mBuilder->isConstructing() || !mProducedUnit->isBeingConstructed()))
				mBuilder->build(mProducedUnit);
		}
	}

	if((isStopped() || isCanceled()) && mProducedUnit && mProducedUnit->exists())
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Attempting to cancel build");
		mProducedUnit->cancel();
	}

	return hasEnded() && !mBuilder && !mProducedUnit;
}
Ejemplo n.º 5
0
void CTerrainTextureManager::RecurseDirectory(const CTerrainPropertiesPtr& parentProps, const VfsPath& path)
{
	//LOGMESSAGE("CTextureManager::RecurseDirectory(%s)", path.string8());

	CTerrainPropertiesPtr props;

	// Load terrains.xml first, if it exists
	VfsPath pathname = path / "terrains.xml";
	if (VfsFileExists(pathname))
		props = GetPropertiesFromFile(parentProps, pathname);
	
	// No terrains.xml, or read failures -> use parent props (i.e. 
	if (!props)
	{
		LOGMESSAGE("CTerrainTextureManager::RecurseDirectory(%s): no terrains.xml (or errors while loading) - using parent properties", path.string8());
		props = parentProps;
	}

	// Recurse once for each subdirectory
	DirectoryNames subdirectoryNames;
	(void)g_VFS->GetDirectoryEntries(path, 0, &subdirectoryNames);
	for (size_t i=0;i<subdirectoryNames.size();i++)
	{
		VfsPath subdirectoryPath = path / subdirectoryNames[i] / "";
		RecurseDirectory(props, subdirectoryPath);
	}

	LoadTextures(props, path);
}
Ejemplo n.º 6
0
	virtual void OnComplete()
	{
		// We've received the game state from an existing player - now
		// we need to send it onwards to the newly rejoining player

		// Find the session corresponding to the rejoining host (if any)
		CNetServerSession* session = NULL;
		for (size_t i = 0; i < m_Server.m_Sessions.size(); ++i)
		{
			if (m_Server.m_Sessions[i]->GetHostID() == m_RejoinerHostID)
			{
				session = m_Server.m_Sessions[i];
				break;
			}
		}

		if (!session)
		{
			LOGMESSAGE("Net server: rejoining client disconnected before we sent to it");
			return;
		}

		// Store the received state file, and tell the client to start downloading it from us
		// TODO: this will get kind of confused if there's multiple clients downloading in parallel;
		// they'll race and get whichever happens to be the latest received by the server,
		// which should still work but isn't great
		m_Server.m_JoinSyncFile = m_Buffer;
		CJoinSyncStartMessage message;
		session->SendMessage(&message);
	}
Ejemplo n.º 7
0
static void shutdownProcess(int signr) {
  if (signr == SIGTERM) {
    LOGMESSAGE("Bye\n");
    rfidDeinit();
    exit(EXIT_SUCCESS);
  }
}
Ejemplo n.º 8
0
CStr CNetServerSession::GetIPAddress() const
{
	char ipAddress[256] = "";
	if (enet_address_get_host_ip(&m_Peer->address, ipAddress, ARRAY_SIZE(ipAddress)) < 0)
		LOGMESSAGE("Could not get IP address of a client!");

	return ipAddress;
}
Ejemplo n.º 9
0
void ConstructionTask::returnUnit(Unit unit)
{
	if(unit == mBuilder)
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Returning Builder");
		freeResources();
		mBuilder = StaticUnits::nullunit;
	}
	else if(unit == mProducedUnit)
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Returning Produced Unit");
		freeResources();
		mProducedUnit = StaticUnits::nullunit;
	}
	else
		assert(!unit->exists());//If it doesn't exist it was a prediction that has been replaced
}
Ejemplo n.º 10
0
void ConstructionTask::reserveLocation()
{
	if(!mReservedLocation && !inProgress() && !hasEnded())
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Reserving Location");
		mReservedLocation = BuildingPlacer::Instance().getBuildingReservation(mBuildingLocation, mType);
		assert(!mReservedLocation->update());
	}
}
Ejemplo n.º 11
0
void ConstructionTask::freeLocation()
{
	if(mReservedLocation)
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Freeing Location");
		mReservedLocation->forceCompleted();
		mReservedLocation.reset();
	}
}
Ejemplo n.º 12
0
void ConstructionTask::freeResources()
{
	if(mReservedResources)
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Freeing Resources");

		ResourceTracker::Instance().releaseCurrentMinerals(mRequiredSatisfyTime, mType.mineralPrice());
		ResourceTracker::Instance().releaseCurrentGas(mRequiredSatisfyTime, mType.gasPrice());
		ResourceTracker::Instance().releaseCurrentSupply(mRequiredSatisfyTime, mType.supplyRequired());
		mReservedResources = false;
	}
}
Ejemplo n.º 13
0
int waitForConnection(int socketDesc){
  int c, clientSock;
  struct sockaddr_in client;

  c = sizeof(struct sockaddr_in);
  clientSock = accept(socketDesc, (struct sockaddr *)&client, (socklen_t*)&c);
  if (clientSock < 0) {
    LOGMESSAGE("Error accepting socket connection\n");
    exit(EXIT_FAILURE);
  }
  return clientSock;
}
Ejemplo n.º 14
0
void ConstructionTask::reserveResources()
{
	if(!mReservedResources && !inProgress() && !hasEnded())
	{
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Reserving Resources");

		ResourceTracker::Instance().reserveCurrentMinerals(mRequiredSatisfyTime, mType.mineralPrice());
		ResourceTracker::Instance().reserveCurrentGas(mRequiredSatisfyTime, mType.gasPrice());
		ResourceTracker::Instance().reserveCurrentSupply(mRequiredSatisfyTime, mType.supplyRequired());
		mReservedResources = true;
	}
}
Ejemplo n.º 15
0
void ConstructionTask::setRequiredSatisfyTime(RequirementGroup requirements, int time, int delay)
{
	if(!mReservedResources)
	{
		mRequiredSatisfyTime = time;
		mRequiredDelayTime = delay;
	}
	else
		LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Required Satisfy Time changed while resources are reserved");

	if(mReservedLocation)
		mReservedLocation->setStartTime(time);
}
Ejemplo n.º 16
0
Status CGUIManager::ReloadChangedFiles(const VfsPath& path)
{
	for (PageStackType::iterator it = m_PageStack.begin(); it != m_PageStack.end(); ++it)
	{
		if (it->inputs.count(path))
		{
			LOGMESSAGE(L"GUI file '%ls' changed - reloading page '%ls'", path.string().c_str(), it->name.c_str());
			LoadPage(*it);
			// TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators
		}
	}

	return INFO::OK;
}
Ejemplo n.º 17
0
bool CMapGeneratorWorker::Run()
{
	m_ScriptInterface->SetCallbackData(static_cast<void*> (this));

	// Replace RNG with a seeded deterministic function
	m_ScriptInterface->ReplaceNondeterministicRNG(m_MapGenRNG);
	m_ScriptInterface->LoadGlobalScripts();

	// Functions for RMS
	m_ScriptInterface->RegisterFunction<bool, std::wstring, CMapGeneratorWorker::LoadLibrary>("LoadLibrary");
	m_ScriptInterface->RegisterFunction<void, CScriptValRooted, CMapGeneratorWorker::ExportMap>("ExportMap");
	m_ScriptInterface->RegisterFunction<void, int, CMapGeneratorWorker::SetProgress>("SetProgress");
	m_ScriptInterface->RegisterFunction<void, CMapGeneratorWorker::MaybeGC>("MaybeGC");
	m_ScriptInterface->RegisterFunction<std::vector<std::string>, CMapGeneratorWorker::GetCivData>("GetCivData");

	// Parse settings
	CScriptValRooted settingsVal = m_ScriptInterface->ParseJSON(m_Settings);
	if (settingsVal.undefined())
	{
		LOGERROR(L"CMapGeneratorWorker::Run: Failed to parse settings");
		return false;
	}

	// Init RNG seed
	uint32_t seed;
	if (!m_ScriptInterface->GetProperty(settingsVal.get(), "Seed", seed))
	{	// No seed specified
		LOGWARNING(L"CMapGeneratorWorker::Run: No seed value specified - using 0");
		seed = 0;
	}

	m_MapGenRNG.seed((int32_t)seed);

	// Copy settings to global variable
	if (!m_ScriptInterface->SetProperty(m_ScriptInterface->GetGlobalObject(), "g_MapSettings", settingsVal))
	{
		LOGERROR(L"CMapGeneratorWorker::Run: Failed to define g_MapSettings");
		return false;
	}

	// Load RMS
	LOGMESSAGE(L"Loading RMS '%ls'", m_ScriptPath.string().c_str());
	if (!m_ScriptInterface->LoadGlobalScriptFile(m_ScriptPath))
	{
		LOGERROR(L"CMapGeneratorWorker::Run: Failed to load RMS '%ls'", m_ScriptPath.string().c_str());
		return false;
	}

	return true;
}
Ejemplo n.º 18
0
int createSocket(){
  int socketDesc;
  struct sockaddr_in server;

  socketDesc = socket(AF_INET, SOCK_STREAM, 0);
  if (socketDesc == -1){
    LOGMESSAGE("Error creating socket\n");
    exit(EXIT_FAILURE);
  }

  server.sin_family = AF_INET;
  //Nur lokale Verbindungen zulassen
  server.sin_addr.s_addr = inet_addr("127.0.0.1");
  server.sin_port = htons(PORT);

  if (bind(socketDesc, (struct sockaddr *)&server, sizeof(server)) < 0){
    LOGMESSAGE("Error binding socket\n");
    exit(EXIT_FAILURE);
  }

  listen(socketDesc, 1);

  return socketDesc;
}
// ---------------------------------------------------------
// CDpMif::SendMessage
// Send ISI message, given receiver device, receiver object,
// resource, transaction id, message id and message.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CDpMif::SendMessage(
    TUint8 aRecDevice,
    TUint8 aRecObject,
    TUint8 aResource,
    TUint8 aTransactionId,
    TUint8 aMessageId,
    const TDesC8& aMessage )
    {
    OstTrace0( TRACE_NORMAL, DUP1_CDPMIF_SENDMESSAGE, "CDpMif::SendMessage" );
    OstTrace1( TRACE_NORMAL, DUP15_CDPMIF_SENDMESSAGE, "CDpMif:: Port: %u", iDataPort.PortUnit() );
    OstTraceExt1( TRACE_NORMAL, DUP14_CDPMIF_SENDMESSAGE, "CDpMif:: ==> receiver dev.: 0x%hhx", aRecDevice );
    OstTraceExt1( TRACE_NORMAL, DUP13_CDPMIF_SENDMESSAGE, "CDpMif:: ==> receiver obj.: 0x%hhx", aRecObject );
    OstTraceExt1( TRACE_NORMAL, DUP12_CDPMIF_SENDMESSAGE, "CDpMif:: ==> resource: 0x%hhx", aResource );
    OstTraceExt1( TRACE_NORMAL, DUP11_CDPMIF_SENDMESSAGE, "CDpMif:: ==> tra id: 0x%hhx", aTransactionId );
    OstTraceExt1( TRACE_NORMAL, DUP10_CDPMIF_SENDMESSAGE, "CDpMif:: ==> msg id: 0x%hhx", aMessageId );

    LOGM1(" CDpMif::SendMessage - Port %d", iDataPort.PortUnit() );
    LOGM1("  ==> receiver dev.: 0x%x", aRecDevice );
    LOGM1("  ==> receiver obj.: 0x%x", aRecObject );
    LOGM1("  ==> resource: 0x%x", aResource );
    LOGM1("  ==> tra id: 0x%x", aTransactionId );
    LOGM1("  ==> msg id: 0x%x", aMessageId );

    // We shall use send buffer
    iSendMessage.Zero();
    TIsiSend msg( iSendMessage );
    msg.Set8bit( ISI_HEADER_OFFSET_RECEIVERDEVICE, aRecDevice );
    msg.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, aResource );
    msg.Set8bit( ISI_HEADER_OFFSET_RECEIVEROBJECT, aRecObject );
    msg.Set8bit( ISI_HEADER_OFFSET_TRANSID, aTransactionId );
    msg.Set8bit( ISI_HEADER_OFFSET_MESSAGEID, aMessageId );
    // Copy message data (+2 => after msgid and traid)
    msg.CopyData( ISI_HEADER_SIZE + 2, aMessage );

    // Add paddings
    while ( iSendMessage.Length() % 4 )
        {
        iSendMessage.Append( 0x00 );
        }

    OstTrace1( TRACE_NORMAL, DUP8_CDPMIF_SENDMESSAGE, "CDpMif:: ==> message length: %d", iSendMessage.Length() );
    OstPrintIsiMessage( iSendMessage );

    LOGM1("  ==> message length: %d", iSendMessage.Length() );
    LOGMESSAGE( iSendMessage );

    return iDataPort.ISAHandle().Send( msg.Complete() );
    }
Ejemplo n.º 20
0
int main (int argc, char *argv[])
{
  int socketDesc;
  int clientSock = -1;
  unsigned int *rfidData;
  LOGMESSAGE("This is rfidaemon\n");

  rfidInit();

  //Handler für das Beenden des Prozesses anmelden
  signal_add(SIGTERM, shutdownProcess);
  signal(SIGPIPE, SIG_IGN);

  //socketDesc = createSocket();
  while (1)
  {
    /*
    //Warten, bis Verbindung mit Socket aufgebaut wurde
    if (clientSock < 0){
      clientSock = waitForConnection(socketDesc);
    }
    */

    //Prüfen, ob ein gültiges Paket empfangen wurde
    if (rfidCheck(&rfidData) == 0) {
      char dataString[13*2+2] = "";
      int i;
      //Daten ausleses
      for (i=0; i<13; i++){
        char tmp[10];
        sprintf(tmp, "%02x", rfidData[i]);
        strcat(dataString, tmp);
      }
      strcat(dataString, "\n");
      /*
      if (write(clientSock, dataString, strlen(dataString))< 0){
        LOGMESSAGE("Client disconnected\n");
        close(clientSock);
        clientSock = -1;
      }
      */
      sendPostRequest(SOURCENAME, dataString);
    }
    sleep(200000);
  }
}
Ejemplo n.º 21
0
bool CSimulation2Impl::LoadScripts(CComponentManager& componentManager, std::set<VfsPath>* loadedScripts, const VfsPath& path)
{
	VfsPaths pathnames;
	if (vfs::GetPathnames(g_VFS, path, L"*.js", pathnames) < 0)
		return false;

	bool ok = true;
	for (const VfsPath& path : pathnames)
	{
		if (loadedScripts)
			loadedScripts->insert(path);
		LOGMESSAGE("Loading simulation script '%s'", path.string8());
		if (!componentManager.LoadScript(path))
			ok = false;
	}
	return ok;
}
Ejemplo n.º 22
0
bool CSimulation2Impl::LoadScripts(const VfsPath& path)
{
	VfsPaths pathnames;
	if (vfs::GetPathnames(g_VFS, path, L"*.js", pathnames) < 0)
		return false;

	bool ok = true;
	for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it)
	{
		VfsPath filename = *it;
		m_LoadedScripts.insert(filename);
		LOGMESSAGE(L"Loading simulation script '%ls'", filename.string().c_str());
		if (! m_ComponentManager.LoadScript(filename))
			ok = false;
	}
	return ok;
}
Ejemplo n.º 23
0
Status CSimulation2Impl::ReloadChangedFile(const VfsPath& path)
{
	// Ignore if this file wasn't loaded as a script
	// (TODO: Maybe we ought to load in any new .js files that are created in the right directories)
	if (m_LoadedScripts.find(path) == m_LoadedScripts.end())
		return INFO::OK;

	// If the file doesn't exist (e.g. it was deleted), don't bother loading it since that'll give an error message.
	// (Also don't bother trying to 'unload' it from the component manager, because that's not possible)
	if (!VfsFileExists(path))
		return INFO::OK;

	LOGMESSAGE(L"Reloading simulation script '%ls'", path.string().c_str());
	if (!m_ComponentManager.LoadScript(path, true))
		return ERR::FAIL;

	return INFO::OK;
}
Ejemplo n.º 24
0
void CNetClient::LoadFinished()
{
	JSContext* cx = GetScriptInterface().GetContext();
	JSAutoRequest rq(cx);

	if (!m_JoinSyncBuffer.empty())
	{
		// We're rejoining a game, and just finished loading the initial map,
		// so deserialize the saved game state now

		std::string state;
		DecompressZLib(m_JoinSyncBuffer, state, true);

		std::stringstream stream(state);

		u32 turn;
		stream.read((char*)&turn, sizeof(turn));
		turn = to_le32(turn);

		LOGMESSAGE("Rejoining client deserializing state at turn %u\n", turn);

		bool ok = m_Game->GetSimulation2()->DeserializeState(stream);
		ENSURE(ok);

		m_ClientTurnManager->ResetState(turn, turn);

		JS::RootedValue msg(cx);
		GetScriptInterface().Eval("({'type':'netstatus','status':'join_syncing'})", &msg);
		PushGuiMessage(msg);
	}
	else
	{
		// Connecting at the start of a game, so we'll wait for other players to finish loading
		JS::RootedValue msg(cx);
		GetScriptInterface().Eval("({'type':'netstatus','status':'waiting_for_players'})", &msg);
		PushGuiMessage(msg);
	}

	CLoadedGameMessage loaded;
	loaded.m_CurrentTurn = m_ClientTurnManager->GetCurrentTurn();
	SendMessage(&loaded);
}
Ejemplo n.º 25
0
	bool Compile(GLhandleARB shader, const VfsPath& file, const CStr& code)
	{
		TIMER_ACCRUE(tc_ShaderGLSLCompile);

		ogl_WarnIfError();

		const char* code_string = code.c_str();
		GLint code_length = code.length();
		pglShaderSourceARB(shader, 1, &code_string, &code_length);

		pglCompileShaderARB(shader);

		GLint ok = 0;
		pglGetShaderiv(shader, GL_COMPILE_STATUS, &ok);

		GLint length = 0;
		pglGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);

		// Apparently sometimes GL_INFO_LOG_LENGTH is incorrectly reported as 0
		// (http://code.google.com/p/android/issues/detail?id=9953)
		if (!ok && length == 0)
			length = 4096;

		if (length > 1)
		{
			char* infolog = new char[length];
			pglGetShaderInfoLog(shader, length, NULL, infolog);

			if (ok)
				LOGMESSAGE(L"Info when compiling shader '%ls':\n%hs", file.string().c_str(), infolog);
			else
				LOGERROR(L"Failed to compile shader '%ls':\n%hs", file.string().c_str(), infolog);

			delete[] infolog;
		}

		ogl_WarnIfError();

		return (ok ? true : false);
	}
Ejemplo n.º 26
0
///////////////////////////////////////////////////////////////////////////////
// GetAnimation: return a given animation by filename; return null if filename 
// doesn't refer to valid animation file
CSkeletonAnimDef* CSkeletonAnimManager::GetAnimation(const VfsPath& pathname)
{
	VfsPath name = pathname.ChangeExtension(L"");

	// Find if it's already been loaded
	boost::unordered_map<VfsPath, CSkeletonAnimDef*>::iterator iter = m_Animations.find(name);
	if (iter != m_Animations.end())
		return iter->second;

	CSkeletonAnimDef* def = NULL;

	// Find the file to load
	VfsPath psaFilename = m_ColladaManager.GetLoadablePath(name, CColladaManager::PSA);

	if (psaFilename.empty())
	{
		LOGERROR(L"Could not load animation '%ls'", pathname.string().c_str());
		def = NULL;
	}
	else
	{
		try
		{
			def = CSkeletonAnimDef::Load(psaFilename);
		}
		catch (PSERROR_File&)
		{
			LOGERROR(L"Could not load animation '%ls'", psaFilename.string().c_str());
		}
	}

	if (def)
		LOGMESSAGE(L"CSkeletonAnimManager::GetAnimation(%ls): Loaded successfully", pathname.string().c_str());
	else
		LOGERROR(L"CSkeletonAnimManager::GetAnimation(%ls): Failed loading, marked file as bad", pathname.string().c_str());

	// Add to map
	m_Animations[name] = def; // NULL if failed to load - we won't try loading it again
	return def;
}
Ejemplo n.º 27
0
void SplashScreen::update() {
    switch (_splashState) {
    case InGame :
        // If InGame propagate draw to field.
        _field->update();
        // Check for termination.
        // TODO: It is better to use lazy approach.
        if (_field->isTerminated()) {
            _splashState = OnSplash;
            _bgmusic.Play();
        }
        break;
    case OnSplash :
        if (!handleEvents()) {
            LOGMESSAGE("ESC!");
            _splashState = Exit;
        }
        break;
    case Exit :
        break;
    }
}
Ejemplo n.º 28
0
	Status ReloadChangedFile(const VfsPath& path)
	{
		// Ignore files that aren't in the right path
		if (!boost::algorithm::starts_with(path.string(), L"art/skeletons/"))
			return INFO::OK;

		if (path.Extension() != L".xml")
			return INFO::OK;

		m_skeletonHashInvalidated = true;

		// If the file doesn't exist (e.g. it was deleted), don't bother reloading
		// or 'unloading' since that isn't possible
		if (!VfsFileExists(path))
			return INFO::OK;

		if (!dll.IsLoaded() && !TryLoadDLL())
			return ERR::FAIL;

		LOGMESSAGE("Hotloading skeleton definitions from '%s'", path.string8());
		// Set the filename for the logger to report
		set_logger(ColladaLog, const_cast<void*>(static_cast<const void*>(&path)));

		CVFSFile skeletonFile;
		if (skeletonFile.Load(m_VFS, path) != PSRETURN_OK)
		{
			LOGERROR("Failed to read skeleton defintions from '%s'", path.string8());
			return ERR::FAIL;
		}

		int ok = set_skeleton_definitions((const char*)skeletonFile.GetBuffer(), (int)skeletonFile.GetBufferSize());
		if (ok < 0)
		{
			LOGERROR("Failed to load skeleton definitions from '%s'", path.string8());
			return ERR::FAIL;
		}

		return INFO::OK;
	}
Ejemplo n.º 29
0
Status L10n::ReloadChangedFile(const VfsPath& path)
{
	if (!boost::algorithm::starts_with(path.string(), L"l10n/"))
		return INFO::OK;

	if (path.Extension() != L".po")
		return INFO::OK;

	// If the file was deleted, ignore it
	if (!VfsFileExists(path))
		return INFO::OK;

	std::wstring dictName = GetFallbackToAvailableDictLocale(currentLocale);
	if (useLongStrings)
		dictName = L"long";
	if (dictName.empty())
		return INFO::OK;

	// Only the currently used language is loaded, so ignore all others
	if (path.string().rfind(dictName) == std::string::npos)
		return INFO::OK;

	LOGMESSAGE("Hotloading translations from '%s'", path.string8());

	CVFSFile file;
	if (file.Load(g_VFS, path) != PSRETURN_OK)
	{
		LOGERROR("Failed to read translations from '%s'", path.string8());
		return ERR::FAIL;
	}

	std::string content = file.DecodeUTF8();
	ReadPoIntoDictionary(content, dictionary);

	if (g_GUI)
		g_GUI->ReloadAllPages();

	return INFO::OK;
}
Ejemplo n.º 30
0
bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName)
{
    // Ignore libraries that are already loaded
    if (m_LoadedLibraries.find(libraryName) != m_LoadedLibraries.end())
    {
        return true;
    }

    // Mark this as loaded, to prevent it recursively loading itself
    m_LoadedLibraries.insert(libraryName);

    VfsPath path = L"maps/random/" + libraryName + L"/";
    VfsPaths pathnames;

    // Load all scripts in mapgen directory
    Status ret = vfs::GetPathnames(g_VFS, path, L"*.js", pathnames);
    if (ret == INFO::OK)
    {
        for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it)
        {
            LOGMESSAGE(L"Loading map generator script '%ls'", it->string().c_str());

            if (!m_ScriptInterface->LoadGlobalScriptFile(*it))
            {
                LOGERROR(L"CMapGeneratorWorker::LoadScripts: Failed to load script '%ls'", it->string().c_str());
                return false;
            }
        }
    }
    else
    {
        // Some error reading directory
        wchar_t error[200];
        LOGERROR(L"CMapGeneratorWorker::LoadScripts: Error reading scripts in directory '%ls': %ls", path.string().c_str(), StatusDescription(ret, error, ARRAY_SIZE(error)));
        return false;
    }

    return true;
}