Example #1
0
Sqf::Value HiveExtApp::playerDeath( Sqf::Parameters params )
{
	int characterId = Sqf::GetIntAny(params.at(0));
	int duration = static_cast<int>(Sqf::GetDouble(params.at(1)));
	
	return booleanReturn(_charData->killCharacter(characterId,duration));
}
Example #2
0
Sqf::Value HiveExtApp::loadPlayer( Sqf::Parameters params )
{
	string playerId = Sqf::GetStringAny(params.at(0));
	string playerName = Sqf::GetStringAny(params.at(2));

	return _charData->fetchCharacterInitial(playerId,getServerId(),playerName);
}
Example #3
0
Sqf::Value HiveExtApp::recordCharacterLogin( Sqf::Parameters params )
{
	string playerId = Sqf::GetStringAny(params.at(0));
	int characterId = Sqf::GetIntAny(params.at(1));
	int action = Sqf::GetIntAny(params.at(2));
	//TODO: Get survivor ID
	return booleanReturn(_charData->recordLogEntry(playerId,0,getServerId(),action));
}
Example #4
0
Sqf::Value HiveExtApp::recordCharacterLogin( Sqf::Parameters params )
{
	string playerId = Sqf::GetStringAny(params.at(0));
	int characterId = Sqf::GetIntAny(params.at(1));
	int action = Sqf::GetIntAny(params.at(2));

	return booleanReturn(_charData->recordLogin(playerId,characterId,action));
}
Example #5
0
Sqf::Value HiveExtApp::playerInit( Sqf::Parameters params )
{
	int characterId = Sqf::GetIntAny(params.at(0));
	Sqf::Value inventory = boost::get<Sqf::Parameters>(params.at(1));
	Sqf::Value backpack = boost::get<Sqf::Parameters>(params.at(2));

	return booleanReturn(_charData->initCharacter(characterId,inventory,backpack));
}
Example #6
0
Sqf::Value HiveExtApp::objectInventory( Sqf::Parameters params, bool byUID /*= false*/ )
{
	Int64 objectIdent = Sqf::GetBigInt(params.at(0));
	Sqf::Value inventory = boost::get<Sqf::Parameters>(params.at(1));

	if (objectIdent != 0) //all the vehicles have objectUID = 0, so it would be bad to update those
		return booleanReturn(_objData->updateObjectInventory(getServerId(),objectIdent,byUID,inventory));

	return booleanReturn(true);
}
Example #7
0
Sqf::Value HiveExtApp::vehicleDamaged( Sqf::Parameters params )
{
	Int64 objectIdent = Sqf::GetBigInt(params.at(0));
	Sqf::Value hitPoints = boost::get<Sqf::Parameters>(params.at(1));
	double damage = Sqf::GetDouble(params.at(2));

	if (objectIdent > 0) //sometimes script sends this with object id 0, which is bad
		return booleanReturn(_objData->updateVehicleStatus(getServerId(),objectIdent,hitPoints,damage));

	return booleanReturn(true);
}
Example #8
0
Sqf::Value HiveExtApp::vehicleMoved( Sqf::Parameters params )
{
	Int64 objectIdent = Sqf::GetBigInt(params.at(0));
	Sqf::Value worldspace = boost::get<Sqf::Parameters>(params.at(1));
	double fuel = Sqf::GetDouble(params.at(2));

	if (objectIdent > 0) //sometimes script sends this with object id 0, which is bad
		return booleanReturn(_objData->updateVehicleMovement(getServerId(),objectIdent,worldspace,fuel));

	return booleanReturn(true);
}
void SqlCustDataSource::populateQuery(string query, Sqf::Parameters& params, CustomDataQueue& queue)
{
	for (int i = 0; i < params.size(); i++)
	{
		query = boost::algorithm::replace_nth_copy(query, "?", i, Sqf::GetStringAny(params.at(i)));
	}

	auto custRes = getDB()->queryParams(query.c_str());

	while (custRes->fetchRow())
	{
		Sqf::Parameters custParams;

		for (int i = 0; i < custRes->numFields(); i++)
		{
			int val = custRes->at(i).getInt32();

			if (val == 0 && custRes->at(i).getString() != "0")
			{
				custParams.push_back(custRes->at(i).getString());
			}
			else
			{
				custParams.push_back(val);
			}
		}

		queue.push(custParams);
	}
}
Example #10
0
Sqf::Value HiveExtApp::objectDelete( Sqf::Parameters params, bool byUID /*= false*/ )
{
	Int64 objectIdent = Sqf::GetBigInt(params.at(0));

	if (objectIdent != 0) //all the vehicles have objectUID = 0, so it would be bad to delete those
		return booleanReturn(_objData->deleteObject(getServerId(),objectIdent,byUID));

	return booleanReturn(true);
}
bool SqlCustDataSource::customExecute(string query, Sqf::Parameters& params) {
	static SqlStatementID stmtId;

	auto stmt = getDB()->makeStatement(stmtId, query);

	for (int i = 0; i < params.size(); i++)
	{
		try
		{
			stmt->addInt32(lexical_cast<int>(params.at(i)));
		}
		catch (bad_lexical_cast)
		{
			stmt->addString(lexical_cast<string>(params.at(i)));
		}
	}

	bool exRes = stmt->execute();
	poco_assert(exRes == true);

	return exRes;
}
Example #12
0
Sqf::Value HiveExtApp::streamCustom( Sqf::Parameters params )
{
	if (_custQueue.empty())
	{
		string query = Sqf::GetStringAny(params.at(0));
		//if (!Sqf::IsNull(params.at(1)))
		Sqf::Parameters rawParams = boost::get<Sqf::Parameters>(params.at(1));

		_custData->populateQuery(query, rawParams, _custQueue);

		Sqf::Parameters retVal;
		retVal.push_back(string("CustomStreamStart"));
		retVal.push_back(static_cast<int>(_custQueue.size()));
		return retVal;
	}
	else
	{
		Sqf::Parameters retVal = _custQueue.front();
		_custQueue.pop();

		return retVal;
	}
}
Example #13
0
Sqf::Value HiveExtApp::objectPublish( Sqf::Parameters params )
{
	string className = boost::get<string>(params.at(1));
	double damage = Sqf::GetDouble(params.at(2));
	int characterId = Sqf::GetIntAny(params.at(3));
	Sqf::Value worldSpace = boost::get<Sqf::Parameters>(params.at(4));
	Sqf::Value inventory = boost::get<Sqf::Parameters>(params.at(5));
	Sqf::Value hitPoints = boost::get<Sqf::Parameters>(params.at(6));
	double fuel = Sqf::GetDouble(params.at(7));
	Int64 uniqueId = Sqf::GetBigInt(params.at(8));

	return booleanReturn(_objData->createObject(getServerId(),className,damage,characterId,worldSpace,inventory,hitPoints,fuel,uniqueId));
}
Example #14
0
Sqf::Value HiveExtApp::objectPublish( Sqf::Parameters params )
{
	/*int serverId = boost::get<int>(params.at(0));
	string className = boost::get<string>(params.at(1));
	string characterId = Sqf::GetIntAny(params.at(2));
	Sqf::Value worldSpace = boost::get<Sqf::Parameters>(params.at(3));
	Int64 uniqueId = Sqf::GetBigInt(params.at(4));
	*/
	int serverId = boost::get<int>(params.at(0));
	string className = boost::get<string>(params.at(1));
	double damage = Sqf::GetDouble(params.at(2));
	int characterId = Sqf::GetIntAny(params.at(3));
	Sqf::Value worldSpace = boost::get<Sqf::Parameters>(params.at(4));
	Sqf::Value inventory = boost::get<Sqf::Parameters>(params.at(5));
	Sqf::Value hitPoints = boost::get<Sqf::Parameters>(params.at(6));
	double fuel = Sqf::GetDouble(params.at(7));
	Int64 uniqueId = Sqf::GetBigInt(params.at(8));
	//return booleanReturn(_objData->createObject(serverId,className,characterId,worldSpace,uniqueId));
	//1:TentStorage:0:3:[329,[11173,3155.13,0.00391388]]:[]:[]:0:111730315510329:|
	return booleanReturn(_objData->createObject(serverId,className,damage,characterId,worldSpace,inventory,hitPoints,fuel,uniqueId));
}
Example #15
0
Sqf::Value HiveExtApp::loadTraderDetails( Sqf::Parameters params )
{
	if (_srvObjects.empty())
	{
		int characterId = Sqf::GetIntAny(params.at(0));

		_objData->populateTraderObjects(characterId, _srvObjects);

		Sqf::Parameters retVal;
		retVal.push_back(string("ObjectStreamStart"));
		retVal.push_back(static_cast<int>(_srvObjects.size()));
		return retVal;
	}
	else
	{
		Sqf::Parameters retVal = _srvObjects.front();
		_srvObjects.pop();

		return retVal;
	}
}
Example #16
0
Sqf::Value HiveExtApp::streamObjects( Sqf::Parameters params )
{
	if (_srvObjects.empty())
	{
		int serverId = boost::get<int>(params.at(0));
		setServerId(serverId);

		_objData->populateObjects(getServerId(), _srvObjects);

		Sqf::Parameters retVal;
		retVal.push_back(string("ObjectStreamStart"));
		retVal.push_back(static_cast<int>(_srvObjects.size()));
		return retVal;
	}
	else
	{
		Sqf::Parameters retVal = _srvObjects.front();
		_srvObjects.pop();

		return retVal;
	}
}
Example #17
0
Sqf::Value HiveExtApp::customExecute( Sqf::Parameters params )
{
	string query = Sqf::GetStringAny(params.at(0));
	Sqf::Parameters rawParams = boost::get<Sqf::Parameters>(params.at(1));
	return _custData->customExecute(query, rawParams);
}
Example #18
0
Sqf::Value HiveExtApp::loadObjectID( Sqf::Parameters params )
{
	Int64 ObjectUID = Sqf::GetBigInt(params.at(0));
	return _charData->fetchObjectId(ObjectUID);
}
Example #19
0
Sqf::Value HiveExtApp::tradeObject( Sqf::Parameters params )
{
	int traderObjectId = Sqf::GetIntAny(params.at(0));
	int action = Sqf::GetIntAny(params.at(1));
	return _charData->fetchTraderObject(traderObjectId, action);
}
Example #20
0
Sqf::Value HiveExtApp::playerUpdate( Sqf::Parameters params )
{
	int characterId = Sqf::GetIntAny(params.at(0));
	CharDataSource::FieldsType fields;

	try
	{
		if (!Sqf::IsNull(params.at(1)))
		{
			Sqf::Parameters worldSpaceArr = boost::get<Sqf::Parameters>(params.at(1));
			if (worldSpaceArr.size() > 0)
			{
				Sqf::Value worldSpace = worldSpaceArr;
				fields["worldspace"] = worldSpace;
			}
		}
		if (!Sqf::IsNull(params.at(2)))
		{
			Sqf::Parameters inventoryArr = boost::get<Sqf::Parameters>(params.at(2));
			if (inventoryArr.size() > 0)
			{
				Sqf::Value inventory = inventoryArr;
				fields["inventory"] = inventory;
			}
		}
		if (!Sqf::IsNull(params.at(3)))
		{
			Sqf::Parameters backpackArr = boost::get<Sqf::Parameters>(params.at(3));
			if (backpackArr.size() > 0)
			{
				Sqf::Value backpack = backpackArr;
				fields["backpack"] = backpack;
			}
		}
		if (!Sqf::IsNull(params.at(4)))
		{
			Sqf::Parameters medicalArr = boost::get<Sqf::Parameters>(params.at(4));
			if (medicalArr.size() > 0)
			{
				for (size_t i=0;i<medicalArr.size();i++)
				{
					if (Sqf::IsAny(medicalArr[i]))
					{
						logger().warning("update.medical["+lexical_cast<string>(i)+"] changed from any to []");
						medicalArr[i] = Sqf::Parameters();
					}
				}
				Sqf::Value medical = medicalArr;
				fields["medical"] = medical;
			}
		}
		if (!Sqf::IsNull(params.at(5)))
		{
			bool justAte = boost::get<bool>(params.at(5));
			if (justAte) fields["just_ate"] = true;
		}
		if (!Sqf::IsNull(params.at(6)))
		{
			bool justDrank = boost::get<bool>(params.at(6));
			if (justDrank) fields["just_drank"] = true;
		}
		if (!Sqf::IsNull(params.at(7)))
		{
			int moreKillsZ = boost::get<int>(params.at(7));
			if (moreKillsZ > 0) fields["zombie_kills"] = moreKillsZ;
		}
		if (!Sqf::IsNull(params.at(8)))
		{
			int moreKillsH = boost::get<int>(params.at(8));
			if (moreKillsH > 0) fields["headshots"] = moreKillsH;
		}
		if (!Sqf::IsNull(params.at(9)))
		{
			int distanceWalked = static_cast<int>(Sqf::GetDouble(params.at(9)));
			if (distanceWalked > 0) fields["DistanceFoot"] = distanceWalked;
		}
		if (!Sqf::IsNull(params.at(10)))
		{
			int durationLived = static_cast<int>(Sqf::GetDouble(params.at(10)));
			if (durationLived > 0) fields["survival_time"] = durationLived;
		}
		if (!Sqf::IsNull(params.at(11)))
		{
			Sqf::Parameters currentStateArr = boost::get<Sqf::Parameters>(params.at(11));
			if (currentStateArr.size() > 0)
			{
				Sqf::Value currentState = currentStateArr;
				fields["state"] = currentState;
			}
		}
		if (!Sqf::IsNull(params.at(12)))
		{
			int moreKillsHuman = boost::get<int>(params.at(12));
			if (moreKillsHuman > 0) fields["survivor_kills"] = moreKillsHuman;
		}
		if (!Sqf::IsNull(params.at(13)))
		{
			int moreKillsBandit = boost::get<int>(params.at(13));
			if (moreKillsBandit > 0) fields["bandit_kills"] = moreKillsBandit;
		}
		if (!Sqf::IsNull(params.at(14)))
		{
			string newModel = boost::get<string>(params.at(14));
			fields["model"] = newModel;
		}
		if (!Sqf::IsNull(params.at(15)))
		{
			int humanityDiff = static_cast<int>(Sqf::GetDouble(params.at(15)));
			if (humanityDiff != 0) fields["humanity"] = humanityDiff;
		}
	}
	catch (const std::out_of_range&)
	{
		logger().warning("Update of character " + lexical_cast<string>(characterId) + " only had " + lexical_cast<string>(params.size()) + " parameters out of 16");
	}

	if (fields.size() > 0)
		return booleanReturn(_charData->updateCharacter(characterId,fields));

	return booleanReturn(true);
}
Example #21
0
void HiveExtApp::callExtension( const char* function, char* output, size_t outputSize )
{
	Sqf::Parameters params;
	try
	{
		params = lexical_cast<Sqf::Parameters>(function);	
	}
	catch(bad_lexical_cast)
	{
		logger().error("Cannot parse function: " + string(function));
		return;
	}

	int funcNum = -1;
	try
	{
		string childIdent = boost::get<string>(params.at(0));
		if (childIdent != "CHILD")
			throw std::runtime_error("First element in parameters must be CHILD");

		params.erase(params.begin());
		funcNum = boost::get<int>(params.at(0));
		params.erase(params.begin());
	}
	catch (...)
	{
		logger().error("Invalid function format: " + string(function));
		return;
	}

	if (handlers.count(funcNum) < 1)
	{
		logger().error("Invalid method id: " + lexical_cast<string>(funcNum));
		return;
	}

	if (logger().debug())
		logger().debug("Original params: |" + string(function) + "|");

	logger().information("Method: " + lexical_cast<string>(funcNum) + " Params: " + lexical_cast<string>(params));
	HandlerFunc handler = handlers[funcNum];
	Sqf::Value res;
	try
	{
		res = handler(params);
	}
	catch (...)
	{
		logger().error("Error executing |" + string(function) + "|");
		return;
	}		

	string serializedRes = lexical_cast<string>(res);
	if (serializedRes.length() >= outputSize)
	{
		logger().error("Output size too big ("+lexical_cast<string>(serializedRes.length())+") for request : " + string(function));
		return;
	}

	logger().information("Result: " + serializedRes);		
	strncpy_s(output,outputSize,serializedRes.c_str(),outputSize-1);
}
Example #22
0
Sqf::Value HiveExtApp::loadCharacterDetails( Sqf::Parameters params )
{
	int characterId = Sqf::GetIntAny(params.at(0));
	
	return _charData->fetchCharacterDetails(characterId);
}