示例#1
0
bool FactoryModule::AddToQueue(uint equipment_type)
{
	if (type == Module::TYPE_M_DOCKING)
	{
		if (equipment_type == 1)
		{
			build_queue.push_back(CreateID(RECIPE_NAMES[equipment_type]));
			return true;
		}
	}
	else if (type == Module::TYPE_M_JUMPDRIVES)
	{
		if (equipment_type == 2
			|| equipment_type == 3
			|| equipment_type == 4)
		{
			build_queue.push_back(CreateID(RECIPE_NAMES[equipment_type]));
			return true;
		}
	}
	else if (type == Module::TYPE_M_HYPERSPACE_SCANNER)
	{
		if (equipment_type == 5
			|| equipment_type == 6
			|| equipment_type == 7)
		{
			build_queue.push_back(CreateID(RECIPE_NAMES[equipment_type]));
			return true;
		}
	}
	else if (type == Module::TYPE_M_CLOAK)
	{
		if (equipment_type == 8
			|| equipment_type == 9
			|| equipment_type == 10
			|| equipment_type == 11)
		{
			build_queue.push_back(CreateID(RECIPE_NAMES[equipment_type]));
			return true;
		}
	}

	else if (type == Module::TYPE_M_CLOAKDISRUPTOR)
	{
		if (equipment_type == 12
			|| equipment_type == 13
			|| equipment_type == 14)
		{
			build_queue.push_back(CreateID(RECIPE_NAMES[equipment_type]));
			return true;
		}
	}
	
	return false;
}
示例#2
0
	void GiveCash::LoadSettings(const string &scPluginCfgFile)
	{
		set_iMinTransfer = IniGetI(scPluginCfgFile, "GiveCash", "MinTransfer", 1);
		set_iMinTime = IniGetI(scPluginCfgFile, "GiveCash", "MinTime", 0);
		set_bCheatDetection = IniGetB(scPluginCfgFile, "GiveCash", "CheatDetection", true);
		set_iBlockedSystem = CreateID(IniGetS(scPluginCfgFile, "GiveCash", "BlockedSystem", "").c_str());
	}
示例#3
0
文件: rep.cpp 项目: dsyalex/FLHook
void REP::LoadSettings()
{
	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\alley_rep.cfg";

	INI_Reader ini;
	if (ini.open(scPluginCfgFile.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("reputations"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("rep"))
						{
							uint solarnick = CreateID(ini.get_value_string(0));
							const char* newrep = ini.get_value_string(1);

							ConPrint(L"DEBUG: Rep of %s is %s \n", stows(ini.get_value_string(0)).c_str(), stows(ini.get_value_string(1)).c_str());
							
							uint obj_rep_group;
							pub::Reputation::GetReputationGroup(obj_rep_group, newrep);
							pub::Reputation::SetAffiliation(solarnick, obj_rep_group);
						}
					}				
				}
			}
		ini.close();
	}
}
示例#4
0
int main()
{
	int menu;

	while (1){

		printf("Main Menu\n");
		printf("1. Librarian mode\n2. Student mode\n3.Create ID\n0.Exit\n\nINPUT: ");
		scanf("%d", &menu);
		switch (menu)
		{
		
		case 1:
			Login_Check();
			break;
		case 2:
			StuLogin();  
			break;
		case 3:
			CreateID();
			break;
		case 0:
			exit(0);

		default:
			printf("Wrong Number.\n\n");
		}
	}
}
示例#5
0
/// Load the configuration
void LoadSettings()
{
	returncode = DEFAULT_RETURNCODE;

	memset(transferFlags, 0, sizeof(int) * (MAX_CLIENT_ID + 1));

	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\conn.ini";

	// Load generic settings
	set_iPluginDebug = IniGetI(scPluginCfgFile, "General", "Debug", 0);
	set_iTargetBaseID = CreateID(IniGetS(scPluginCfgFile, "General", "TargetBase", "li06_05_base").c_str());
	set_iTargetSystemID = CreateID(IniGetS(scPluginCfgFile, "General", "TargetSystem", "li06").c_str());
	set_iRestrictedSystemID = CreateID(IniGetS(scPluginCfgFile, "General", "RestrictedSystem", "iw09").c_str());
	set_iDefaultBaseID = CreateID(IniGetS(scPluginCfgFile, "General", "DefaultBase", "li01_proxy_base").c_str());
}
示例#6
0
	foreach (lstValues, INISECTIONVALUE, it2)
	{
		string scFaction = Trim(GetParam(it2->scKey, ',', 1));
		if (!scFaction.length())
			continue;

		uint iFactionID;
		pub::Reputation::GetReputationGroup(iFactionID, scFaction.c_str());
		set_mAffiliationTokens[CreateID(Trim(GetParam(it2->scKey, ',', 0)).c_str())] = iFactionID;
	}
示例#7
0
bool HkLoadBaseMarket()
{
	INI_Reader ini;

	if(!ini.open("..\\data\\equipment\\market_misc.ini", false))
		return false;

	while(ini.read_header())
	{
		try {
			if(!ini.is_header("BaseGood"))
				throw "";
			if(!ini.read_value())
				throw "";
			if(!ini.is_value("base"))
				throw "";

			const char *szBaseName = ini.get_value_string();
			BASE_INFO *biBase = 0;
			foreach(lstBases, BASE_INFO, it)
			{
				const char *szBN = it->scBasename.c_str();
				if(!ToLower(it->scBasename).compare(ToLower(szBaseName)))
				{
					biBase = &(*it);
					break;
				}
			}

			if(!biBase)
				throw ""; // base not found

			ini.read_value();

			biBase->lstMarketMisc.clear();
			if(!ini.is_value("MarketGood"))
				throw "";

			do {
				DATA_MARKETITEM mi;
				const char *szEquipName = ini.get_value_string(0);
				mi.iArchID = CreateID(szEquipName);
				mi.fRep = ini.get_value_float(2);
				biBase->lstMarketMisc.push_back(mi);
			} while(ini.read_value());

		} catch(char*) {}
	}

	ini.close();
	return true;
}
示例#8
0
EXPORT void LoadSettings()
{
	list<INISECTIONVALUE> lstValues;
	string set_scCfgItemsFile;
    char szCurDir[MAX_PATH];
    GetCurrentDirectory(sizeof(szCurDir), szCurDir);
    set_scCfgItemsFile = string(szCurDir) + "\\flhook_plugins\\Itemrestrictions.ini";

	IniGetSection(set_scCfgItemsFile, "ExcludeTradeItems", lstValues);
	set_btNoTrade->Clear();
	foreach(lstValues, INISECTIONVALUE, it11)
	{
		UINT_WRAP *uw = new UINT_WRAP(CreateID(it11->scKey.c_str()));
		set_btNoTrade->Add(uw);
	}
示例#9
0
void LoadSettings()
{
	returncode = DEFAULT_RETURNCODE;

	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\tokens.ini";

	list<INISECTIONVALUE> lstValues;
	IniGetSection(scPluginCfgFile, "NoPvpTokens", lstValues);
	set_vNoPvpGoodIDs.clear();
	foreach (lstValues, INISECTIONVALUE, it1)
	{
		set_vNoPvpGoodIDs.push_back(CreateID(Trim(GetParam(it1->scKey, ',', 0)).c_str()));
	}
示例#10
0
	void AntiJumpDisconnect::CharacterInfoReq(unsigned int iClientID, bool p2)
	{
		if (mapInfo[iClientID].bInWrapGate)   
		{
			uint iShip;
			pub::Player::GetShip(iClientID, iShip);
			pub::SpaceObj::SetInvincible(iShip, false, false, 0);
			IObjInspectImpl *obj = HkGetInspect(iClientID);
			if (obj)
			{
				HkLightFuse((IObjRW*)obj, CreateID("death_comm"), 0.0f, 0.0f, 0.0f);
			}
			HkTempBan(iClientID, 5);
		}
	}
示例#11
0
void AP::LoadSettings()
{
	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\alley_permissions.cfg";

	INI_Reader ini;
	if (ini.open(scPluginCfgFile.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("angels"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("permission"))
						{
							angels.push_back(stows(ini.get_value_string()));
						}
					}				
				}
				else if (ini.is_header("event"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("permission"))
						{
							events.push_back(stows(ini.get_value_string()));
						}
					}	
				}
				else if (ini.is_header("bastillebase"))
				{
					while (ini.read_value())
					{
						if (ini.is_value("base"))
						{
							uint base = CreateID(ini.get_value_string());
							bastillebase[base] = base; 
						}
					}
				}
			}
		ini.close();
	}
}
示例#12
0
EXPORT void LoadSettings()
{
	returncode = DEFAULT_RETURNCODE;
	list<INISECTIONVALUE> value;
	string set_scCargoPod;
	char szCurDir[MAX_PATH];
    GetCurrentDirectory(sizeof(szCurDir), szCurDir);
    set_scCargoPod = string(szCurDir) + "\\flhook_plugins\\CargoPod.ini";
	IniGetSection(set_scCargoPod, "CargoPod", value);
	set_btCargoPod->Clear();
	foreach(value, INISECTIONVALUE, lst)
	{
		uint PodID;
		PodID = CreateID(lst->scKey.c_str());
		CARGO_POD *pod = new CARGO_POD(PodID,atoi(lst->scValue.c_str()));
		set_btCargoPod->Add(pod);
	}
示例#13
0
/// Read an ini file for nicknames and save the associated hashcode
static void ReadIniNicknameFile(const string &filePath)
{
	INI_Reader ini;
	if (ini.open(filePath.c_str(), false))
	{
		while (ini.read_header())
		{
			while (ini.read_value())
			{
				if (ini.is_value("nickname"))
				{
					uint hash = CreateID(Trim(ToLower(ini.get_value_string())).c_str());
					mapHashToNickname[hash] = ini.get_value_string();
				}
			}
		}
		ini.close();
	}
}
示例#14
0
文件: mail.cpp 项目: invicnaper/MWF
bool SendMail(string sFrom, string sTo, string sSubject, string sBody, bool bIsHTML, string sSendMailPath, string* pErrorMessage)
{
    string message = "";

    if(sFrom != "") message.append("From: " + sFrom + "\r\n");
    if(sTo != "") message.append("To: " + sTo + "\r\n");
    if(sSubject != "") message.append("Subject: " + sSubject + "\r\n");
    if(bIsHTML)
        message.append("Content-Type: text/html\r\n");
    else
        message.append("Content-Type: text/plain\r\n");

    if(sBody != "") message.append(sBody);

    string temp_file_name = TempDir() + CreateID(sFrom + sTo) + ".tmp";
    if(!FileSaveString(temp_file_name, message, 0, pErrorMessage))
        return false;

	string sendmail_path = "";
	if(sSendMailPath == "")
		sendmail_path = DEFAULT_SENDMAIL_PATH;
	else
		sendmail_path = sSendMailPath;

    string arguments = "";
    arguments.append("-t < ");
    arguments.append("\"" + temp_file_name + "\"");
    if(!Execute(sendmail_path, arguments, true, pErrorMessage))
    {
        FileDelete(temp_file_name, NULL);
        return false;
    }

    FileDelete(temp_file_name, NULL);

    return true;
}
示例#15
0
bool AdminCmd_ChangeSystem(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
{
	wstring wscArg = ToLower(GetParam(wscParam, ' ', 0));
	//check master switch bruh
	if (!bPluginEnabled)
	{
		PrintUserCmdText(iClientID, L"ChangeSys is disabled.\n");
		return true;
	}
	if (wscArg.length()==0)
	{
		PrintUserCmdText(iClientID, L"ERR Incorrect Parameters <sys|list>");
		return true;
	}
	//check what the parameters are
	if (wcscmp(wscArg.c_str(), L"list") == 0)
	{
		//show list of systems
		PrintUserCmdText(iClientID, L"list of systems: ");
		/*for (vector<string>::iterator it = bPluginAllowedSystems.begin(); it != bPluginAllowedSystems.end(); ++it) 
		{
			PrintUserCmdText(iClientID, stows(*it));
		}*/
		PrintUserCmdText(iClientID, stows(bPluginAllowedSystemsFriendly));
		return true;
	}
	//assume player is trying to enter a system id
	uint ship;
	pub::Player::GetShip(iClientID, ship);
	if (!ship)
	{
		PrintUserCmdText(iClientID, L"ERR Not in space\n");
		return true;
	}
	
	//check if valid sys id from config vector
	if(find(bPluginAllowedSystems.begin(), bPluginAllowedSystems.end(), wstos(wscArg)) != bPluginAllowedSystems.end())
	{ 
		//its a match buddy!
		//do tha magic
		//get system id for server
		uint iTargetSystem = CreateID(wstos(wscArg).c_str());
		Vector pos;
		Matrix ornt;
		//get the pos and ornt of ship
		pub::SpaceObj::GetLocation(ship, pos, ornt);
		//move player
		SwitchSystem(iClientID, iTargetSystem, pos, ornt);
		PrintUserCmdText(iClientID, L"Moving to system: ");
		PrintUserCmdText(iClientID, wscArg.c_str());
		PrintUserCmdText(iClientID, L"OK\n");
		//done magic
	}
	else
	{
		//well f**k
		PrintUserCmdText(iClientID, L"ERR Invalid system id: ");
		PrintUserCmdText(iClientID, wscArg.c_str());
	}

	return true;
}
示例#16
0
	foreach(lstValues, INISECTIONVALUE, it16)
	{
		UINT_WRAP *uw = new UINT_WRAP(CreateID(it16->scKey.c_str()));
		set_setNoSpaceItems->Add(uw);
	}
示例#17
0
// Find the recipe for this building_type and start construction.
BuildModule::BuildModule(PlayerBase *the_base, uint the_build_type)
	: Module(TYPE_BUILD), base(the_base), build_type(the_build_type)
{	
	uint module_nickname = CreateID(MODULE_TYPE_NICKNAMES[build_type]);
	active_recipe = recipes[module_nickname];
}
示例#18
0
	foreach(lstValues, INISECTIONVALUE, it4)
	{
		set_btJRestrict->Add(new DOCK_RESTRICTION(CreateID(it4->scKey.c_str()), CreateID((Trim(GetParam(it4->scValue, ',', 0))).c_str()), ToInt(Trim(GetParam(it4->scValue, ',', 1))), stows(Trim(GetParamToEnd(it4->scValue, ',', 2)))));
	}
示例#19
0
文件: Main.cpp 项目: HeIIoween/FLHook
void LoadSettings()
{
	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\event.cfg";

	INI_Reader ini;
	set_mapCargoMissions.clear();
	set_mapNpcMissions.clear();
	if (ini.open(scPluginCfgFile.c_str(), false))
	{
		while (ini.read_header())
		{	
			if (ini.is_header("General"))
			{
				while (ini.read_value())
				{
					if (ini.is_value("debug"))
					{ 
						set_iPluginDebug = ini.get_value_int(0);
					}
					else if (ini.is_value("cargo"))
					{
						CARGO_MISSION mis;
						mis.nickname = ini.get_value_string(0);
						mis.base = CreateID(ini.get_value_string(1));
						mis.item = CreateID(ini.get_value_string(2));
						mis.required_amount = ini.get_value_int(3);
						set_mapCargoMissions.insert(multimap<uint, CARGO_MISSION>::value_type(mis.base, mis));
					}
					else if (ini.is_value("npc"))
					{
						NPC_MISSION mis;
						mis.nickname = ini.get_value_string(0);
						mis.system = CreateID(ini.get_value_string(1));
						mis.sector = ini.get_value_string(2);
						pub::Reputation::GetReputationGroup(mis.reputation, ini.get_value_string(3));
						mis.required_amount = ini.get_value_int(4);
						set_mapNpcMissions.insert(multimap<uint, NPC_MISSION>::value_type(mis.reputation, mis));
					}
				}
			}
			ini.close();
		}

		if (set_iPluginDebug&1)
		{
			ConPrint(L"CargoMissionSettings loaded [%d]\n",set_mapCargoMissions.size());
			ConPrint(L"NpcMissionSettings loaded [%d]\n",set_mapNpcMissions.size());
		}
		ini.close();
	}
	
	// Read the last saved event status
	char szDataPath[MAX_PATH];
	GetUserDataPath(szDataPath);
	string scStatsPath = string(szDataPath) + "\\Accts\\MultiPlayer\\event_stats.txt";	
	if (ini.open(scStatsPath.c_str(), false))
	{
		while (ini.read_header())
		{	
			if (ini.is_header("Missions"))
			{
				while (ini.read_value())
				{
					if (ini.is_value("cargo"))
					{
						string nickname = ini.get_value_string(0);
						int curr_amount = ini.get_value_int(2);

						for (multimap<uint, CARGO_MISSION>::iterator i = set_mapCargoMissions.begin();
							i != set_mapCargoMissions.end(); ++i)
						{
							if (i->second.nickname == nickname)
							{
								i->second.curr_amount = curr_amount;
							}
						}
					}
					else if (ini.is_value("npc"))
					{
						NPC_MISSION mis;
						string nickname = ini.get_value_string(0);
						int curr_amount = ini.get_value_int(2);

						for (multimap<uint, NPC_MISSION>::iterator i = set_mapNpcMissions.begin();
							i != set_mapNpcMissions.end(); ++i)
						{
							if (i->second.nickname == nickname)
							{
								i->second.curr_amount = curr_amount;
							}
						}
					}
				}
			}
		}
		ini.close();
	}
}
示例#20
0
文件: Main.cpp 项目: HeIIoween/FLHook
void LoadSettings()
{
	returncode = DEFAULT_RETURNCODE;

	// The path to the configuration file.
	string marketshipsfile = "..\\data\\equipment\\market_ships.ini";
	string marketcommoditiesfile = "..\\data\\equipment\\market_commodities.ini";
	string flhookitems = "..\\exe\\flhook_plugins\\alley_mf.cfg";
	int shipamount1 = 0;
	int shipamount2 = 0;
	int commodamount1 = 0;
	int commodamount2 = 0;

	INI_Reader ini;
	if (ini.open(marketshipsfile.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("BaseGood"))
				{
					while (ini.read_value())
					{
						uint currentbase;
						if (ini.is_value("base"))
						{
							currentbase = CreateID(ini.get_value_string(0));
							shipamount1 = shipamount1 + 1;
						}
						else if (ini.is_value("marketgood"))
						{
						    mapACShips[currentbase].push_back(CreateID(ini.get_value_string(0)));
							shipamount2 = shipamount2 + 1;
						}
					}				
				}
			}
		ini.close();
	}
	if (ini.open(marketcommoditiesfile.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("BaseGood"))
				{
					while (ini.read_value())
					{
						//uint temple = CreateID("st04_03_base");
						uint bastilleguard = CreateID("iw09_03_base");
						uint currentbase;
						if (ini.is_value("base"))
						{
							currentbase = CreateID(ini.get_value_string(0));
							//we don't record operations from the temple of the damned so when we come across it we'll ignore it.
							//if (currentbase == temple)
							//{							
							//	ConPrint(L"MARKETFUCKER: Ignoring Temple of the Damned. \n");		
							//}
							if (currentbase == bastilleguard)
							{							
								ConPrint(L"MARKETFUCKER: Ignoring Bastille Guard Station. \n");		
							}
							else
							{
								mapACBases.push_back(currentbase);
								commodamount1 = commodamount1 + 1;
							}
						}
					}				
				}
			}
		ini.close();
	}
	if (ini.open(flhookitems.c_str(), false))
	{
		while (ini.read_header())
			{
				if (ini.is_header("items"))
				{
					while (ini.read_value())
					{
						uint currentitem;
						if (ini.is_value("item"))
						{
								currentitem = CreateID(ini.get_value_string(0));
								//mapACItems.push_back(currentitem);
								mapACItems[currentitem] = ini.get_value_string(0);
								commodamount2 = commodamount2 + 1;
						}
					}				
				}
			}
		ini.close();
	}

	ConPrint(L"MARKETFUCKER: Loaded %u ships for %u bases \n", shipamount2, shipamount1);
	ConPrint(L"MARKETFUCKER: Loaded %u items for %u bases \n", commodamount2, commodamount1);
}
示例#21
0
/**
Parse the specified ini file (usually in the data/solar/asteriods) and retrieve 
the lootable zone details. 
*/
void ReadLootableZone(zone_map_t &set_mmapZones, const string &systemNick, const string &defaultZoneNick, const string &file)
{
	string path="..\\data\\";
	path += file;

	INI_Reader ini;
	if (ini.open(path.c_str(), false))
	{
		while (ini.read_header())
		{
			if (ini.is_header("LootableZone"))
			{
				string zoneNick=defaultZoneNick;
				string crateNick="";
				string lootNick="";
				int iMinLoot = 0;
				int iMaxLoot = 0;
				uint iLootDifficulty = 0;
				while (ini.read_value())
				{
					if (ini.is_value("zone"))
					{
						zoneNick=ToLower(ini.get_value_string());
					}
					else if (ini.is_value("dynamic_loot_container"))
					{
						crateNick=ToLower(ini.get_value_string());
					}
					else if (ini.is_value("dynamic_loot_commodity"))
					{
						lootNick=ToLower(ini.get_value_string());
					}
					else if (ini.is_value("dynamic_loot_count"))
					{
						iMinLoot=ini.get_value_int(0);
						iMaxLoot=ini.get_value_int(1);
					}
					else if (ini.is_value("dynamic_loot_difficulty"))
					{
						iLootDifficulty=ini.get_value_int(0);
					}
				}

				LOOTABLE_ZONE lz;
				lz.systemID = CreateID(systemNick.c_str());
				lz.zoneNick = zoneNick;
				lz.lootNick = lootNick;
				lz.iLootID = CreateID(lootNick.c_str());
				lz.iCrateID = CreateID(crateNick.c_str());
				lz.iMinLoot = iMinLoot;
				lz.iMaxLoot = iMaxLoot;
				lz.iLootDifficulty = iLootDifficulty;
				lz.pos.x = lz.pos.y = lz.pos.z = 0;
				lz.size.x = lz.size.y = lz.size.z = 0;

				bool exists = false;
				for (zone_map_iter_t i=set_mmapZones.begin(); i!=set_mmapZones.end(); i++)
				{
					if (i->second.zoneNick==zoneNick)
					{
						exists = true;
						break;
					}
				}
				if (!exists)
					set_mmapZones.insert(zone_map_pair_t(lz.systemID,lz));
			}
		}
		ini.close();
	}
}
示例#22
0
string CWRequest::CreateSessionID()
{
    return CreateID("session_id");
}
示例#23
0
void Siege::SiegeGunDeploy(uint client, const wstring &args)
{
	// Abort processing if this is not a "heavy lifter"
	uint shiparch;
	pub::Player::GetShipID(client, shiparch);
	if (set_construction_shiparch != 0 && shiparch != set_construction_shiparch)
	{
		PrintUserCmdText(client, L"ERR Need deployment ship");
		return;
	}

	uint ship;
	pub::Player::GetShip(client, ship);
	if (!ship)
	{
		PrintUserCmdText(client, L"ERR Not in space");
		return;
	}

	// If the ship is moving, abort the processing.
	Vector dir1;
	Vector dir2;
	pub::SpaceObj::GetMotion(ship, dir1, dir2);
	if (dir1.x>5 || dir1.y>5 || dir1.z>5)
	{
		PrintUserCmdText(client, L"ERR Ship is moving");
		return;
	}

	int min = 100;
	int max = 5000;
	int randomsiegeint = min + (rand() % (int)(max - min + 1));

	string randomname = "Siege Cannon AX-" + randomsiegeint;

	// Check for conflicting base name
	if (GetPlayerBase(CreateID(PlayerBase::CreateBaseNickname(randomname).c_str())))
	{
		PrintUserCmdText(client, L"ERR Deployment error, please reiterate.");
		return;
	}

	// Check that the ship has the requires commodities.
	int hold_size;
	list<CARGO_INFO> cargo;
	HkEnumCargo((const wchar_t*)Players.GetActiveCharacterName(client), cargo, hold_size);
	for (map<uint, uint>::iterator i = construction_items.begin(); i != construction_items.end(); ++i)
	{
		bool material_available = false;
		uint good = i->first;
		uint quantity = i->second;
		for (list<CARGO_INFO>::iterator ci = cargo.begin(); ci != cargo.end(); ++ci)
		{
			if (ci->iArchID == good && ci->iCount >= (int)quantity)
			{
				material_available = true;
				pub::Player::RemoveCargo(client, ci->iID, quantity);
			}
		}
		if (material_available == false)
		{
			PrintUserCmdText(client, L"ERR Construction failed due to insufficient raw material.");
			for (i = construction_items.begin(); i != construction_items.end(); ++i)
			{
				const GoodInfo *gi = GoodList::find_by_id(i->first);
				if (gi)
				{
					PrintUserCmdText(client, L"|  %ux %s", i->second, HkGetWStringFromIDS(gi->iIDSName).c_str());
				}
			}
			return;
		}
	}

	wstring charname = (const wchar_t*)Players.GetActiveCharacterName(client);
	AddLog("NOTICE: Base created %s by %s (%s)",
		randomname.c_str(),
		wstos(charname).c_str(),
		wstos(HkGetAccountID(HkGetAccountByCharname(charname))).c_str());

	wstring password = L"hastesucks";
	wstring basename = stows(randomname);

	PlayerBase *newbase = new PlayerBase(client, password, basename);
	player_bases[newbase->base] = newbase;
	newbase->basetype = "siegegun";
	newbase->basesolar = "depot";
	newbase->baseloadout = "depot";
	newbase->defense_mode = 1;

	for (map<string, ARCHTYPE_STRUCT>::iterator iter = mapArchs.begin(); iter!=mapArchs.end(); iter++)
	{

		ARCHTYPE_STRUCT &thearch = iter->second;
		if (iter->first == newbase->basetype) 
		{					
			newbase->invulnerable = thearch.invulnerable;
			newbase->logic = thearch.logic;
		}
	}

	newbase->Spawn();
	newbase->Save();

	PrintUserCmdText(client, L"OK: Siege Cannon deployed");
	PrintUserCmdText(client, L"Default administration password is %s", password.c_str());
}
示例#24
0
int CSingleUser::OnRespone_ReqOrderInsert(CTdxApi* pApi, RequestRespone_STRUCT* pRespone)
{
	Order_STRUCT* pTdxOrder = (Order_STRUCT*)pRespone->pContent;
	OrderField* pOrder = (OrderField*)pRespone->pUserData_Public2;

	WTLB_STRUCT* pWTOrders = new WTLB_STRUCT;
	strcpy(pWTOrders->ZJZH, pTdxOrder->ZJZH);
	strcpy(pWTOrders->GDDM, pTdxOrder->GDDM);
	strcpy(pWTOrders->WTBH, pTdxOrder->WTBH);
	strcpy(pWTOrders->JYSDM, pTdxOrder->ZHLB_);
	pWTOrders->Client = m_pClient;

	m_pApi->m_id_api_order.insert(pair<string, WTLB_STRUCT*>(pOrder->LocalID, pWTOrders));
	// 处理错误
	if (pRespone->pErr)
	{
		pOrder->RawErrorID = pRespone->pErr->ErrCode;
		strcpy(pOrder->Text, pRespone->pErr->ErrInfo);
	}

	// 处理结果
	if (pRespone->ppResults&&pRespone->ppResults[0 * COL_EACH_ROW + 0])
	{
		// 写上柜台的ID,以后将基于此进行定位
		strcpy(pOrder->OrderID, pRespone->ppResults[0 * COL_EACH_ROW + 0]);//订单号
		strcpy(pWTOrders->WTBH, pOrder->OrderID);
		CreateID(pOrder->ID, nullptr, pTdxOrder->GDDM, pOrder->OrderID);
		

		m_pApi->m_id_api_order.erase(pOrder->LocalID);
		m_pApi->m_id_api_order.insert(pair<string, WTLB_STRUCT*>(pOrder->ID, pWTOrders));

		m_pApi->m_id_platform_order.erase(pOrder->LocalID);
		m_pApi->m_id_platform_order.insert(pair<string, OrderField*>(pOrder->ID, pOrder));
		
		// 有挂单的,需要进行查询了

		double  _queryTime = QUERY_TIME_MIN;
		m_QueryOrderTime = time(nullptr) + _queryTime;
		OutputQueryTime(m_QueryOrderTime, _queryTime, "NextQueryOrder_Send");
	}

	// 现在有两个结构体,需要进行操作了
	// 1.通知下单的结果
	// 2.记录下单

	OrderField* pField = pOrder;
	if (pField->RawErrorID != 0)
	{
		pField->ExecType = ExecType::ExecType_Rejected;
		pField->Status = OrderStatus::OrderStatus_Rejected;
	}
	else
	{
		pField->ExecType = ExecType::ExecType_New;
		pField->Status = OrderStatus::OrderStatus_New;
	}

	m_msgQueue->Input_Copy(ResponeType::ResponeType_OnRtnOrder, m_msgQueue, m_pClass, 0, 0, pField, sizeof(OrderField), nullptr, 0, nullptr, 0);

	return 0;
}
示例#25
0
int CSingleUser::OnRespone_ReqQryOrder(CTdxApi* pApi, RequestRespone_STRUCT* pRespone)
{
	ReqQueryData_STRUCT* pQuery = (ReqQueryData_STRUCT*)pRespone->pContent;

	if (pRespone->pErr)
	{
		ErrorField* pField = (ErrorField*)m_msgQueue->new_block(sizeof(ErrorField));

		pField->RawErrorID = pRespone->pErr->ErrCode;
		strcpy(pField->Text, pRespone->pErr->ErrInfo);
		strcpy(pField->Source, "OnRespone_ReqQryOrder");

		m_msgQueue->Input_NoCopy(ResponeType::ResponeType_OnRtnError, m_msgQueue, m_pClass, 0, 0, pField, sizeof(ErrorField), nullptr, 0, nullptr, 0);
	}

	WTLB_STRUCT** ppRS = nullptr;
	CharTable2WTLB(pRespone->ppFieldInfo, pRespone->ppResults, &ppRS, pRespone->Client);

	// 操作前清空,按说之前已经清空过一次了
	m_NewOrderList.clear();

	// 有未完成的,标记为true
	bool IsDone = true;
	// 有未申报的,标记为true
	bool IsNotSent = false;
	// 有更新的
	bool IsUpdated = false;

	if (ppRS)
	{
		int i = 0;
		while (ppRS[i])
		{
			// 将撤单委托过滤
			if (ppRS[i]->MMBZ_ != MMBZ_Cancel && ppRS[i]->MMBZ_ != MMBZ_Buy_Cancel && ppRS[i]->MMBZ_ != MMBZ_Sell_Cancel)
			{
				// 需要将它输入到一个地方用于计算,这个是临时的,需要删除
				OrderField* pField = (OrderField*)m_msgQueue->new_block(sizeof(OrderField));

				WTLB_2_OrderField_0(ppRS[i], pField);
				CreateID(pField->ID, ppRS[i]->WTRQ, ppRS[i]->GDDM, ppRS[i]->WTBH);
				pField->Date = ppRS[i]->WTRQ_ == 0 ? Today(0) : ppRS[i]->WTRQ_;//日期为0,重新赋值

				m_NewOrderList.push_back(pField);

				if (!ZTSM_IsDone(ppRS[i]->ZTSM_))
				{
					IsDone = false;
				}
				if (ZTSM_IsNotSent(ppRS[i]->ZTSM_))
				{
					IsNotSent = true;
				}

				// 需要将其保存起来,是只保存一次,还是每次都更新呢?个人认为只保存一次即可,反正是用来撤单的
				unordered_map<string, WTLB_STRUCT*>::iterator it = m_pApi->m_id_api_order.find(pField->ID);
				if (it == m_pApi->m_id_api_order.end())
				{
					WTLB_STRUCT* pWTField = (WTLB_STRUCT*)m_msgQueue->new_block(sizeof(WTLB_STRUCT));
					memcpy(pWTField, ppRS[i], sizeof(WTLB_STRUCT));
					m_pApi->m_id_api_order.insert(pair<string, WTLB_STRUCT*>(pField->ID, pWTField));
				}
			}
			++i;
		}
	}

	// 委托列表
	// 1.新增的都需要输出
	// 2.老的看是否有变化
	++m_OrderNotUpdateCount;

	int i = 0;
	list<OrderField*>::iterator it2 = m_OldOrderList.begin();
	for (list<OrderField*>::iterator it = m_NewOrderList.begin(); it != m_NewOrderList.end(); ++it)
	{
		OrderField* pField = *it;

		bool bUpdate = false;
		if (i >= m_OldOrderList.size())
		{
			bUpdate = true;
		}
		else
		{
			// 相同位置的部分
			OrderField* pOldField = *it2;
			if (pOldField->LeavesQty != pField->LeavesQty || pOldField->Status != pField->Status)
			{
				bUpdate = true;
			}
		}

		if (bUpdate)
		{
			IsUpdated = true;
			m_OrderNotUpdateCount = 0;

			// 如果能找到下单时的委托,就修改后发出来
			unordered_map<string, OrderField*>::iterator it = m_pApi->m_id_platform_order.find(pField->ID);
			if (it == m_pApi->m_id_platform_order.end())
			{
				// 因为上次生成的可能在后期删了,所以要复制一份
				OrderField* pField_ = (OrderField*)m_msgQueue->new_block(sizeof(OrderField));
				memcpy(pField_, pField, sizeof(OrderField));

				m_pApi->m_id_platform_order.insert(pair<string, OrderField*>(pField_->ID, pField_));
			}
			else
			{
				OrderField* pField_ = it->second;
				memcpy(pField_, pField, sizeof(OrderField));
			}

			m_msgQueue->Input_Copy(ResponeType::ResponeType_OnRtnOrder, m_msgQueue, m_pClass, 0, 0, pField, sizeof(OrderField), nullptr, 0, nullptr, 0);
		}

		// 前一个可能为空,移动到下一个时需要注意
		if (it2 != m_OldOrderList.end())
		{
			++it2;
		}

		++i;
	}

	if (pQuery->bAll)
	{
		int i = 0;
		int count = m_NewOrderList.size();
		for (list<OrderField*>::iterator it = m_NewOrderList.begin(); it != m_NewOrderList.end(); ++it)
		{
			OrderField* pField = *it;
			m_msgQueue->Input_Copy(ResponeType::ResponeType_OnRspQryOrder, m_msgQueue, m_pClass, i == count - 1, 0, pField, sizeof(OrderField), nullptr, 0, nullptr, 0);
			++i;
		}
	}

	// 将老数据清理,防止内存泄漏
	for (list<OrderField*>::iterator it = m_OldOrderList.begin(); it != m_OldOrderList.end(); ++it)
	{
		OrderField* pField = *it;
		m_msgQueue->delete_block(pField);
	}

	// 做交换
	m_OldOrderList.clear();
	m_OldOrderList = m_NewOrderList;
	m_NewOrderList.clear();

	double _queryTime = 0;
	if (!IsDone)
	{
		if (!IsUpdated)
		{
			// 没有更新,是否要慢点查
			_queryTime = 0.5 * QUERY_TIME_MAX + QUERY_TIME_MIN;
		}

		// 有没有完成的,需要定时查询
		if (IsNotSent)
		{
			// 有没申报的,是否没在交易时间?慢点查
			_queryTime = 0.5 * QUERY_TIME_MAX + QUERY_TIME_MIN;
		}
		else
		{
			// 可能是交易时间了,是否需要考虑
			_queryTime = 2 * QUERY_TIME_MIN;
			// 可能有些挂单一天都不会成交,挂在这一直导致查太多,加一下查询计数
			if (m_OrderNotUpdateCount >= 3)
			{
				_queryTime = 0.5 * QUERY_TIME_MAX + QUERY_TIME_MIN;
			}
		}
	}
	else
	{
		// 全完成了,可以不查或慢查
		_queryTime = 5 * QUERY_TIME_MAX;
	}

	m_QueryOrderTime = time(nullptr) + _queryTime;
	OutputQueryTime(m_QueryOrderTime, _queryTime, "NextQueryOrder_QueryOrder");

	// 决定成交查询间隔
	if (IsUpdated)
	{
		// 委托可能是撤单,也有可能是成交了,赶紧查一下
		_queryTime = 0;
		m_QueryTradeTime = time(nullptr) + _queryTime;
		OutputQueryTime(m_QueryTradeTime, _queryTime, "NextQueryTrade_QueryOrder");
	}
	else
	{
		// 委托没有变化,那成交就没有必要查那么快了
		_queryTime = 5 * QUERY_TIME_MAX;
		m_QueryTradeTime = time(nullptr) + _queryTime;
		OutputQueryTime(m_QueryTradeTime, _queryTime, "NextQueryTrade_QueryOrder");
	}

	return 0;
}
示例#26
0
string CWRequest::CreateRequestID()
{
    return CreateID("request_id");
}