Ejemplo n.º 1
0
void VerbApplyEnhancement::onExecute()
{
	NounShip * pShip = WidgetCast<NounShip>( target() );
	if ( context()->isServer() && validate(pShip) && validate(m_pCargo) )
	{
		NounEnhancement::Ref pEnhancement = m_pCargo->enhancement();
		if ( pEnhancement && pEnhancement->parent() == NULL && pEnhancement->canUse( pShip ) )
		{
			// this will attach the contained enhancement to the ship...
			if ( pEnhancement->use( pShip ) )
			{
				// detach the cargo item now..
				pShip->detachNode( m_pCargo );

				pShip->privateChat( CharString().format( "<color;ffffff>Enhancement: Using <color;%6.6x>%s</color> on %s.", 
					pEnhancement->color().RGB(),pEnhancement->getName(), pShip->name() ) );
				LOG_STATUS( "VerbApplyEnhancement", "[ENHANCEMENT]:Apply:%u:%s:%s", 
					pShip->userId(), pEnhancement->getName(),pShip->name() );

				// save off storage with this "active" ship
				context()->user()->saveStorage(pShip);
			}
			else
			{
				pShip->privateChat( CharString().format( "<color;ffffff>Enhancement: Failed to use enhancement <color;%6.6x>%s</color>.",
					pEnhancement->color().RGB(), pEnhancement->getName() ) );
			}
		}
	}
}
Ejemplo n.º 2
0
void GameDocument::onShipCaptured( Noun * pCapper )
{
	TRACE( "GameDocument::onShipCaptured" );

	setGameState( GS_DEATH );
	m_bShipLost = true;

	// inform our script
	CharString sSelf = ship()->key().string();
	CharString sCapper = pCapper != NULL ? pCapper->key().string() : "";
	context()->scriptCall( CharString().format("onCaptured( '%s''%s' )", sSelf, sCapper ) );
	
	// reset the camera time
	s_fCamera = 0.0f;

	WindowObserve * pWindow = WidgetCast<WindowObserve>( InterfaceContext::findNode( "ObserveWindow" ) );
	if ( pWindow != NULL )
	{
		pWindow->setCameraMode( WindowObserve::CHASE );
		pWindow->setTargetMode( WindowObserve::LOCKED );
		pWindow->setTarget( ship() );
	}

	WindowText * pMessage = WidgetCast<WindowText>( InterfaceContext::findNode( "TextMessage" ) );
	if ( pMessage != NULL )
	{
		if ( pCapper != NULL )
			pMessage->setText( CharString().format("Ship captured by %s...", pCapper->name()) );
		else
			pMessage->setText( "Ship captured..." );
	}
}
Ejemplo n.º 3
0
CharString GadgetBeamWeapon::useTip( Noun * pTarget, bool shift ) const
{
	if ( shift )
		return "Toggle Point Defense.";
	
	// usage information
	CharString tip;
	float fEnergyMod = calculateModifier( MT_BEAM_ENERGY );
	float fChargeScale = damageRatioInv() * fEnergyMod;
	tip += CharString().format("\nRecharge Time:   <X;100>%.1fs", energyCost() / ( ( energyCharge() * fChargeScale ) * TICKS_PER_SECOND ) );
	tip += CharString().format("\nEnergy Cost:<X;100>%.1f", energyCost() / 1000.0f );
	float fLength = length() * calculateModifier( MT_BEAM_RANGE );
	tip += CharString().format("\nMax Range:<X;100>%.1fgu", fLength );
	
	// direct damage
	float fDamageMod = calculateModifier( MT_BEAM_DAMAGE );
	float fDamage = damage() * fDamageMod;
	if ( damageRandom() > 0 )
	{
		float fMaxDamage = fDamage + (damageRandom() * fDamageMod);
		tip += CharString().format( "\nDamage:<X;100>%.0f-%.0f", fDamage * duration(), fMaxDamage * duration() );
	}
	else
		tip += CharString().format( "\nDamage:<X;100>%.1f", fDamage * duration() );

	return tip;
}
Ejemplo n.º 4
0
CharString GadgetDrive::useTip( Noun * pTarget, bool shift ) const
{
	CharString tip;
	
	// usage information
	int generate = 0;
	if ( active() )
	{
		generate = damageRatioInv() * this->energy();
		// reduce energy based on velocity
		NounShip * pShip = WidgetCast<NounShip>( parent() );
		if ( pShip != NULL )
		{
			if ( energyFalloff() > 0 && pShip->maxVelocity() > 0.0f && pShip->velocity() > pShip->baseVelocity() )
			{
				float scale = ( pShip->velocity() - pShip->baseVelocity() ) / pShip->velocityRange();
				generate -= ( energyFalloff() * scale) ;
			}
		}
	}
	
	tip += CharString().format("\nEnergy p/s:<X;100>%.1f", ( generate * TICKS_PER_SECOND ) / 1000.0f );
	tip += CharString().format("\nEnergy Stored:<X;100>%.0f", maxEnergy() / 1000.0f );	
	
	return tip;
}
Ejemplo n.º 5
0
bool ButtonCargo::onCursorMove( const RectInt & window, const PointInt & position, const PointInt & delta )
{
	if ( WindowButton::onCursorMove( window, position, delta ) )
	{
		GameDocument * pDoc = (GameDocument *)document();
		ASSERT( pDoc );
		NounShip * pShip = pDoc->ship();
		if (! pShip )
			return false;
		Noun * pCargo = m_Cargo;
		if (! pCargo )
			return false;

		pDoc->setLeftHint( CharString().format( "TARGET %s", pCargo->name() ) );

		Noun * pTarget = pDoc->target();
		if ( WidgetCast<CargoEnhancement>( pCargo ) 
			&& VerbApplyEnhancement::canApply( (CargoEnhancement *)pCargo, pShip ) )
			pDoc->setRightHint( CharString().format( "USE %s", pCargo->name() ) );
		else if ( pTarget != NULL && pShip->canUnload( pTarget, pCargo ) )
			pDoc->setRightHint( CharString().format( "UNLOAD %s ONTO %s", pCargo->name(), pTarget->name() ) );
		else
			pDoc->setRightHint( "" );

		return true;
	}

	return false;
}
Ejemplo n.º 6
0
Error PaymentService::purchase(Variant p_params) {

	Dictionary params = p_params;
	ERR_FAIL_COND_V((!params.has("product_id")) && (!params.has("product_sku")), ERR_INVALID_PARAMETER);

	char* id = NULL;
	char* sku = NULL;

	CharString p_id = params.has("product_id")?String(params["product_id"]).ascii():CharString();
	CharString p_sku = params.has("product_sku")?String(params["product_sku"]).ascii():CharString();
	unsigned int request_id;
	chdir(launch_dir_ptr);
	int ret = paymentservice_purchase_request(params.has("product_sku") ? NULL : p_id.get_data(),
											  params.has("product_sku") ? p_sku.get_data() : NULL,
											  NULL, NULL, NULL, NULL, get_window_group_id(), &request_id);
	chdir("app/native");

	if (ret != BPS_SUCCESS) {
		int eret = errno;
		printf("purchase error %i, %x, %i, %x\n", ret, ret, eret, eret);
		ERR_FAIL_V((Error)eret);
		return (Error)eret;
	};
	return OK;
};
Ejemplo n.º 7
0
CharString NounShip::status() const
{
	CharString sTargetInfo;

	// team & ship type..
	sTargetInfo += CharString().format("%s - %s\n", teamName(), nounContext()->name() );
	// hull %
	sTargetInfo += CharString().format("Hull: %d%%\n", int( damageRatioInv() * 100) );

	int armor = 0, maxArmor = 0;
	int shield = 0, maxShield = 0;
	for(int i=0;i<childCount();i++)
	{
		BaseNode * pChild = child(i);
		if ( WidgetCast<GadgetShield>( pChild ) )
		{
			shield += ((GadgetShield *)pChild)->charge();
			maxShield += ((GadgetShield *)pChild)->maxCharge();
		}
		else if ( WidgetCast<GadgetArmor>( pChild ) )
		{
			armor += ((GadgetArmor *)pChild)->armor();
			maxArmor += ((GadgetArmor *)pChild)->maxArmor();
		}
	}

	if ( maxShield > 0 )
		sTargetInfo += CharString().format("Shield: %d%%\n", (shield * 100) / maxShield);
	if ( maxArmor > 0 )
		sTargetInfo += CharString().format("Armor: %d%%\n", (armor * 100) / maxArmor );

	return sTargetInfo;
}
Ejemplo n.º 8
0
bool ProcessServer::loadProcessList()
{
	AutoLock lock( &m_Lock );

	m_ProcessList.release();

	Settings pf( "ProcessList", m_Context.processFile );
	m_NextProcessId = pf.get( "NextProcessId", m_NextProcessId );

	int nProcessCount = pf.get( "ProcessCount", (dword)0 );
	for(int i=0;i<nProcessCount;i++)
	{
		Process process;
		process.processId = pf.get( CharString().format("ProcessId%d", i), i + 1 );
		process.name = pf.get( CharString().format("ProcessName%d", i), "" );
		process.executable = pf.get( CharString().format("ProcessExe%d", i), "" );
		process.arguments = pf.get( CharString().format("ProcessArg%d", i), "" );
		process.config = pf.get( CharString().format("ProcessConfig%d", i), "" );
		process.log = pf.get( CharString().format("ProcessLog%d", i), "" );
		
		process.flags = (u16)pf.get( CharString().format("ProcessFlags%d", i), 0xffff );
		if ( process.flags == 0xffff )
		{
			process.flags = 0;
			if ( pf.get( CharString().format("ProcessRunning%d", i), (dword)0 ) != 0 )
				process.flags |= ProcessClient::PF_RUNNING;
			if ( pf.get( CharString().format("ProcessDisabled%d", i), (dword)1 ) != 0 )
				process.flags |= ProcessClient::PF_DISABLED;
		}

		m_ProcessList.push( process );
	}

	return true;
}
Ejemplo n.º 9
0
void EEditorManager::onComponentAction ( QAction* action )
{
	QString componentTypeName = action->text();
	const QString& name = GetSelectObj();
	EditorEvent editorevent;
	editorevent.mType = action->isChecked() ? eEditorToScene_ComponentAttach
		: eEditorToScene_ComponentDettach;
	editorevent.mArgs.push_back ( CharString ( name.toStdString().c_str() ) );
	editorevent.mArgs.push_back ( CharString ( componentTypeName.toStdString().c_str() ) );
	Notify( editorevent );
}
Ejemplo n.º 10
0
CharString GadgetArmor::useTip( Noun * pTarget, bool shift ) const
{
	CharString tip;
	
	// usage information
	tip += CharString().format("\nCurrent HP:<X;100>%d/%d", m_Armor, maxArmor() );
	float fMod = ( calculateModifier( MT_DEFENSE ) * 100 ) - 100;
	if ( fMod > 0 )
		tip += CharString().format("\nDamage Reduction:<X;100>%.0f%%", fMod );
	fMod = calculateModifier( MT_DEFENSE_RECHARGE );

	return tip;
}
Ejemplo n.º 11
0
void JukeboxDS::saveConfig()
{
	Settings config( ("Jukebox"), m_JukeboxConfig );

	config.put( ("listCount"), m_PlayLists.size() );
	for(int i=0;i<m_PlayLists.size();i++)
	{
		config.put( CharString().format(("List%dName"), i), m_PlayLists[i].name );
		config.put( CharString().format(("List%dFileCount"), i ), m_PlayLists[i].files.size() );

		for(int j=0;j<m_PlayLists[i].files.size();j++)
			config.put( CharString().format(("List%dFile%d"), i, j), m_PlayLists[i].files[j] );
	}
}
Ejemplo n.º 12
0
void ButtonCargo::onUpdate( float t )
{
	WindowButton::onUpdate( t );

	if ( enabled() )
	{
		Noun * pCargo = m_Cargo;
		if (! pCargo )
			return;

		if ( WidgetCast<CargoEnhancement>( pCargo ) )
		{
			setTip(((CargoEnhancement *)pCargo)->status());
			m_HotKey = 0;
			return;
		}

		GameDocument * pDoc = (GameDocument *)document();
		ASSERT( pDoc );
		NounShip * pShip = pDoc->ship();
		if (! pShip )
			return;

		bool validAction = false;

		Noun * pTarget = pDoc->target();
		if ( pTarget != NULL )
		{
			if ( pShip->canUnload( pTarget, pCargo ) )
			{
				setTip( CharString().format( "Unload %s onto %s", 
					pCargo->name(), pTarget->name() ) );
				setIconColor( WHITE );

				validAction = true;
				m_HotKey = 'U';
			}
		}

		if ( !validAction )
		{
			if ( WidgetCast<NounUnit>( pCargo ) )
				setTip( CharString().format("%s %s", pCargo->name(), ((NounUnit *)pCargo)->status() ) );
			else
				setTip( pCargo->name() );
			setIconColor( GREY );
			m_HotKey = 0;
		}
	}
}
Ejemplo n.º 13
0
bool JukeboxDS::initialize( const char * pFilePath, int volume )
{
	release();

	// build the file list
	m_FilePath = Path( pFilePath ).directory();
	if (! m_FilePath.endsWith(("\\")) )
		m_FilePath += ("\\");
	m_JukeboxConfig = m_FilePath + ("config.ini");

	// load the jukebox configuration if the file exists
	if ( FileDisk::fileExists( m_JukeboxConfig ) )
	{
		Settings config( ("Jukebox"), m_JukeboxConfig );

		int listCount = config.get( ("listCount"), (dword)0 );
		for(int i=0;i<listCount;i++)
		{
			int newList = addPlayList( config.get( CharString().format( ("List%dName"), i ), ("") ) );
			int fileCount = config.get( CharString().format(("List%dFileCount"), i ), (dword)0 );

			for(int j=0;j<fileCount;j++)
				addTrack( newList, config.get( CharString().format(("List%dFile%d"), i, j), ("")) );
		}
	}
	else
	{
		// create a default playlist with all mp3 files in the directory
		addTrack( addPlayList( ("Default") ), m_FilePath + ("*.mp3") );
		// save configuration
		//saveConfig();
	}

	if ( !m_PlayLists.isValid( 0 ) )
		return false;
	if ( !m_PlayLists[ 0 ].files.isValid( 0 ) )
		return false;

	m_ActiveList = 0;
	m_CurrentTrack = 0;

	m_Volume = Clamp( volume, 0, 100 );

	// start the thread
	play();

	return true;
}
Ejemplo n.º 14
0
void ProcessServer::onConnect( dword client )
{
	LOG_STATUS( "ProcessServer", CharString().format("Connecting client %u from %s", client, clientAddress( client )) );

	AutoLock lock( &m_Lock );
	m_ClientValid[ client ] = false;
}
Ejemplo n.º 15
0
void WindowButton::updateTip()
{
	if ( m_HotKey != 0 )
		updateTip( CharString().format("%s  '%s'", m_Tip, keyText( Keyboard::unmap( m_HotKey ) ) ) );
	else
		updateTip( m_Tip );
}
Ejemplo n.º 16
0
bool ButtonGadget::onCursorMove( const RectInt & window, const PointInt & position, const PointInt & delta )
{
	if ( WindowButton::onCursorMove( window, position, delta ) )
	{
		GameDocument * pDoc = (GameDocument *)document();
		ASSERT( pDoc );
		
		pDoc->setLeftHint( CharString().format( "TARGET %s", m_Gadget->name() ) );
		pDoc->setRightHint( CharString().format( "USE %s", m_Gadget->name() ) );
		m_bCursorOver = true;
		return true;
	}

	m_bCursorOver = false;
	return false;
}
Ejemplo n.º 17
0
void ButtonCargo::setCargo( Noun * pCargo )
{
	m_Cargo = pCargo;

	// set the tool tip
	if ( WidgetCast<NounUnit>( pCargo ) )
	{
		setTip( CharString().format("%s %s", pCargo->name(), ((NounUnit *)pCargo)->status() ) );
		setIcon( ((NounUnit *)pCargo)->icon() );
	}
	else if(WidgetCast<CargoEnhancement>( pCargo ) )
	{
		CargoEnhancement * pCargoEnhancement = (CargoEnhancement *)pCargo;
		
		setTip( pCargoEnhancement->status() );
		if ( pCargoEnhancement->enhancement() != NULL )
		{
			setIcon( pCargoEnhancement->enhancement()->icon() );
			setColor( pCargoEnhancement->enhancement()->color() );
		}	
	}
	else 
	{
		setTip( pCargo->name() );
		setIcon( pCargo->icon() );
	}

	setEnable( true );
}
Ejemplo n.º 18
0
CharString &CharString::append(const char *s, int32_t sLength, UErrorCode &errorCode) {
    if(U_FAILURE(errorCode)) {
        return *this;
    }
    if(sLength<-1 || (s==NULL && sLength!=0)) {
        errorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return *this;
    }
    if(sLength<0) {
        sLength=uprv_strlen(s);
    }
    if(sLength>0) {
        if(s==(buffer.getAlias()+len)) {
            // The caller wrote into the getAppendBuffer().
            if(sLength>=(buffer.getCapacity()-len)) {
                // The caller wrote too much.
                errorCode=U_INTERNAL_PROGRAM_ERROR;
            } else {
                buffer[len+=sLength]=0;
            }
        } else if(buffer.getAlias()<=s && s<(buffer.getAlias()+len) &&
                  sLength>=(buffer.getCapacity()-len)
        ) {
            // (Part of) this string is appended to itself which requires reallocation,
            // so we have to make a copy of the substring and append that.
            return append(CharString(s, sLength, errorCode), errorCode);
        } else if(ensureCapacity(len+sLength+1, 0, errorCode)) {
            uprv_memcpy(buffer.getAlias()+len, s, sLength);
            buffer[len+=sLength]=0;
        }
    }
    return *this;
}
Ejemplo n.º 19
0
Archivo: string.cpp Proyecto: 93i/godot
godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) {
	const String *self = (const String *)p_self;
	godot_char_string result;

	memnew_placement(&result, CharString(self->ascii()));

	return result;
}
Ejemplo n.º 20
0
void GameDocument::onSetSelf( Noun * pShip )
{
	if ( pShip )
	{
		TRACE( CharString().format("GameDocument::onShipSelected, pShip = %p", pShip) );
		m_bShipLost = false;

		context()->scriptCall( CharString().format("onShipAttached( %s )", pShip->key().string()) );

		if ( m_GameState == GS_SERVER_TRANSFER )
			setGameState( GS_GAME );
	}
	else
	{
		onShipDetached();
	}
}
Ejemplo n.º 21
0
CharString DatabaseMYSQL::field(QueryHandle hQuery, int f ) const
{
	QueryResult * pQuery = (QueryResult *)hQuery;
	if ( pQuery == NULL || pQuery->pResult == NULL )
		return "";
	MYSQL_FIELD * pField = mysql_fetch_field_direct( pQuery->pResult, f );
	return pField != NULL ? CharString( pField->name ) : "";
}
Ejemplo n.º 22
0
void LogClient::onDisconnect()
{
	LOG_STATUS( "LogClient", CharString().format( "LogClient disconnected from %s:%d", (const char *)m_sAddress, m_nPort) );

	m_bLoggedIn = false;
	m_bConnected = false;
	m_nLogLevel = LL_STATUS;
}
Ejemplo n.º 23
0
void CChatFrame::OnJoinRoom( UINT nID )
{
	clearIdleTime();

	int roomIndex = nID - ID_ROOM_BEGIN;
	if ( roomIndex < 0 || roomIndex >= m_Rooms.size() )
		return;

	MetaClient & client = CGCQLApp::sm_MetaClient;

	CharString password;
	if ( (m_Rooms[ roomIndex ].flags & MetaClient::FLAG_ROOM_PASSWORD) != 0 )
		if ( (client.profile().flags & MetaClient::MODERATOR) == 0 )
		{
			CRoomPassword dialog( this );
			if ( dialog.DoModal() != IDOK )
				return;

			password = dialog.m_Password;
		}

	// leave our previous room..
	if ( m_nRoomId != 0 )
	{
		client.leaveRoom( m_nRoomId );
		m_nRoomId = 0;
	}

	// join chat room
	if ( (m_nRoomId = client.joinRoom( m_Rooms[ roomIndex ].roomId, password ) ) != 0 )
	{
		// post local message, so the client can know that they have joined a room
		client.sendLocalChat( CharString().format("/Joining '%s'...", m_Rooms[ roomIndex ].name ) );

		if ( CGCQLApp::sm_RoomAnnounce )
			client.sendChat( m_nRoomId, CharString().format("/me has entered the room...", client.profile().name) );

		// set my status
		client.sendStatus( CharString().format("Chatting in '%s'", m_Rooms[ roomIndex ].name.cstr() ) );
	}
	else
	{
		client.sendLocalChat( "Failed to join chat room!" );
	}
}
Ejemplo n.º 24
0
void GameDocument::onPreUpdate()
{
	// display number of lines and triangles rendered
	Profiler::message( 4, CharString().format("Triangles Rendered: %u, Lines Rendered: %u", 
		DisplayDevice::sm_nTrianglesRendered, DisplayDevice::sm_nLinesRendered) );

	// reset the triangle / line counters
	DisplayDevice::sm_nTrianglesRendered = DisplayDevice::sm_nLinesRendered = 0;
}
Ejemplo n.º 25
0
void GadgetScript::use( dword when, Noun * pTarget, bool shift )
{
	Text * pText = getScript();
	if ( pText != NULL )
	{
		message( "Running script..." );
		context()->runScript( UniqueNumber(), "GadgetScript", CharString( pText->text() ) );
	}
}
Ejemplo n.º 26
0
void VerbSetStructureActive::onExecute()
{
	NounStructure * pStructure = WidgetCast<NounStructure>( target() );
	if ( validate( pStructure ) )
	{
		pStructure->setActive( m_bActive );

		if ( pStructure->isServer() && validate( m_pWho ) && validate( pStructure->planet() ) )
		{
			NounPlanet * pPlanet = pStructure->planet();
			ASSERT( pPlanet );

			pStructure->factionChat( m_bActive ? 
				CharString().format( "<color;ffffff>Comms: %s %s activated by %s.", pPlanet->name(), pStructure->name(), m_pWho->name()) :
				CharString().format( "<color;ffffff>Comms: %s %s deactivated by %s.", pPlanet->name(), pStructure->name(), m_pWho->name()) );
		}
	}
}
Ejemplo n.º 27
0
void GadgetELF::use( dword when, Noun * pTarget, bool shift)
{
	if ( active() )
		NounGadget::use( when, pTarget, shift );

	// set the device active
	setFlags( FLAG_ACTIVE, !active() );
	message( CharString().format( "<color;ffffff>Tactical: %s %s.", name(), active() ? "Active" : "Inactive" ) ); 
}
Ejemplo n.º 28
0
void GameDocument::onWorldTransform( const Vector3 & transform )
{
	TRACE( CharString().format( "GameDocument::onWorldTransform (%s)", (CharString)transform) );

	// update all static camera positions by the shift in the zone positions
	s_vCamera += transform;
	WindowNavigation::sm_vCameraTarget += transform;
	ViewTactical::sm_AdjustPosition += transform;
	ViewTactical::sm_CameraPosition += transform;
}
Ejemplo n.º 29
0
void GameDocument::onServerTransfer( const WorldClient::TransferRequest & a_Req )
{
#ifdef _DEBUG
	Settings settings( "ClientD" );
#else
	Settings settings( "Client" );
#endif
	settings.put( "transferAddress", CharString().format( "%s:%d", a_Req.m_sAddress, a_Req.m_nPort) );

	setGameState( GS_SERVER_TRANSFER );
}
Ejemplo n.º 30
0
void testHashMap() {
    cout << "HashMap => ";
    HashMap<CharString> hm = HashMap<CharString>(40000);
    CharString t1 = CharString("test1");
    CharString* t1v = new CharString("asdlkfjhlaksgh;\"'x';\30\1");
    CharString t2 = CharString("test2");
    CharString* t2v = new CharString("data2");
    hm.add(t1,t1v);
    hm.add(t2,t2v);

    CharString str1 = *hm.get(t1);
    bool test1 = str1.Compare(*t1v);
    CharString str2 = *hm.get(t2);
    bool test2 = str2.Compare(*t2v);
    if(test1 && test2) {
        cout << "Pass" << endl;
    } else {
        cout << "Fail" << endl;
    }
}