예제 #1
0
/* copy pasta from playercntl as to provide independance*/
bool MailSend(const wstring &wscCharname, const string &scExtension, const wstring &wscMsg)
{
	// Get the target player's message file.
	string scFilePath = GetUserFilePath(wscCharname, scExtension);
	if (scFilePath.length() == 0)
		return false;

	// Move all mail up one slot starting at the end. We automatically
	// discard the oldest messages.
	for (int iMsgSlot = MAX_MAIL_MSGS - 1; iMsgSlot>0; iMsgSlot--)
	{
		wstring wscTmpMsg = IniGetWS(scFilePath, "Msgs", itos(iMsgSlot), L"");
		IniWriteW(scFilePath, "Msgs", itos(iMsgSlot + 1), wscTmpMsg);

		bool bTmpRead = IniGetB(scFilePath, "MsgsRead", itos(iMsgSlot), false);
		IniWrite(scFilePath, "MsgsRead", itos(iMsgSlot + 1), (bTmpRead ? "yes" : "no"));
	}

	// Write message into the slot
	IniWriteW(scFilePath, "Msgs", "1", GetTimeString(set_bLocalTime) + L" " + wscMsg);
	IniWrite(scFilePath, "MsgsRead", "1", "no");
	return true;
}
예제 #2
0
파일: Mail.cpp 프로젝트: dsyalex/FLHook
	/**
		Delete a message
	*/
	bool MailDel(const wstring &wscCharname, const string &scExtension, int iMsg)
	{
		// Get the target player's message file.
		string scFilePath = GetUserFilePath(wscCharname, scExtension);
		if (scFilePath.length()==0)
			return false;

		// Move all mail down one slot starting at the deleted message to overwrite it
		for (int iMsgSlot = iMsg; iMsgSlot<MAX_MAIL_MSGS; iMsgSlot++)
		{
			wstring wscTmpMsg = IniGetWS(scFilePath, "Msgs", itos(iMsgSlot+1), L"");
			IniWriteW(scFilePath, "Msgs", itos(iMsgSlot), wscTmpMsg);

			bool bTmpRead = IniGetB(scFilePath, "MsgsRead", itos(iMsgSlot+1), false);
			IniWrite(scFilePath, "MsgsRead", itos(iMsgSlot), (bTmpRead?"yes":"no"));
		}
		return true;
	}
예제 #3
0
HK_ERROR HkSetAdmin(const wstring &wscCharname, const wstring &wscRights)
{
	HK_GET_CLIENTID(iClientID, wscCharname);
	CAccount *acc;
	if(iClientID == -1) {
		flstr *str = CreateWString(wscCharname.c_str());
		acc = Players.FindAccountFromCharacterName(*str);
		FreeWString(str);
		if(!acc)
			return HKE_CHAR_DOES_NOT_EXIST;;
	} else {
		acc = Players.FindAccountFromClientID(iClientID);
	}

	wstring wscDir;
	HkGetAccountDirName(acc, wscDir);
	string scAdminFile = scAcctPath + wstos(wscDir) + "\\flhookadmin.ini";
	IniWrite(scAdminFile, "admin", "rights", wstos(wscRights));
	return HKE_OK;
}
예제 #4
0
파일: Mail.cpp 프로젝트: dsyalex/FLHook
	/** Show five messages from the specified starting position. */
	void MailShow(const wstring &wscCharname, const string &scExtension, int iFirstMsg)
	{
		// Make sure the character is logged in.
		uint iClientID = HkGetClientIdFromCharname(wscCharname);
		if (iClientID==-1)
			return;

		// Get the target player's message file.
		string scFilePath = GetUserFilePath(wscCharname, scExtension);
		if (scFilePath.length()==0)
			return;

		int iLastMsg = iFirstMsg;
		for (int iMsgSlot = iFirstMsg, iMsgCount = 0; iMsgSlot<MAX_MAIL_MSGS && iMsgCount<5; iMsgSlot++, iMsgCount++)
		{
			wstring wscTmpMsg = IniGetWS(scFilePath, "Msgs", itos(iMsgSlot), L"");
			if (wscTmpMsg.length()==0)
				break;
			PrintUserCmdText(iClientID, L"#%02d %s", iMsgSlot, wscTmpMsg.c_str());
			IniWrite(scFilePath, "MsgsRead", itos(iMsgSlot), "yes");
			iLastMsg = iMsgSlot;
		}
		PrintUserCmdText(iClientID, L"Viewing #%02d-#%02d of %02d messages", iFirstMsg, iLastMsg, MailCount(wscCharname, scExtension));
	}
예제 #5
0
//---------------------------------------------------------------------------------------------
// Name:
// Desc:
//---------------------------------------------------------------------------------------------
HRESULT CManipulator::SaveConfig(wchar_t* file)
{
	int i;
	wchar_t string[512];
	wchar_t name[512];
	int pid;
	cprimitive* parent;


	

	FILE* file2 = _wfopen(file,L"w+");
	if(file2 == NULL) MessageBox(0,0,0,0);
	fclose(file2);

	//chains
	swprintf(string, L"%d", numOfChains);
	IniWrite(file,L"manipulator",L"chainsize",string);


	for(i=0; i < numOfChains; i++)
	{
		swprintf(name, L"chain_%d", i);

		//coefficient
		swprintf(string, L"%.2f", cube[i]->fCoefficient);
		IniWrite(file, name, L"coefficient", string);

		//direction
		swprintf(string, L"%.2f", cube[i]->fDirection);
		IniWrite(file, name, L"direction", string);

		//displace
		swprintf(string, L"%.2f", cube[i]->fDisplace);
		IniWrite(file, name, L"displace", string);

		//length
		swprintf(string, L"%.2f", cube[i]->fLength);
		IniWrite(file, name, L"length", string);

		//width
		swprintf(string, L"%.2f", cube[i]->fWidth);
		IniWrite(file, name, L"width", string);

		//initangle
		swprintf(string, L"%.2f %.2f", (float)cube[i]->vAngle.x, (float)cube[i]->vAngle.y);
		IniWrite(file, name, L"initangle", string);

		//angle_restrict_phi
		swprintf(string, L"%.2f %.2f", cube[i]->restrictAngleX.x, cube[i]->restrictAngleX.y);
		IniWrite(file, name, L"angle_restrict_phi", string);

		//angle_restrict_theta
		swprintf(string, L"%.2f %.2f", cube[i]->restrictAngleY.x, cube[i]->restrictAngleY.y);
		IniWrite(file, name, L"angle_restrict_theta", string);

		//offset
		swprintf(string, L"%.2f %.2f %.2f", cube[i]->vOffset.x, cube[i]->vOffset.y, cube[i]->vOffset.z);
		IniWrite(file, name, L"offset", string);

		//mass
		swprintf(string, L"%.2f", cube[i]->fMass);
		IniWrite(file, name, L"mass", string);

		//booleans
		IniWrite(file, name, L"tilt", (cube[i]->bTilt ? L"1" : L"0"));
		IniWrite(file, name, L"pressure", (cube[i]->bPressure ? L"1" : L"0"));
		IniWrite(file, name, L"laser", (cube[i]->bLaser ? L"1" : L"0"));

		//parent_index
		parent = GetParent(cube[i],cube[0]);
		if(parent == NULL) pid = -1;
		else pid = parent->id;

		swprintf(string,L"%d",pid);
		IniWrite(file, name, L"parent_index", string);

		IniWrite(file, name, L"model", L"");

		
	}

	//limbs
	swprintf(string, L"%d", limbs.size());
	IniWrite(file,L"limbs",L"num",string);

	for(i=0; i<limbs.size();i++)
	{
		swprintf(name, L"limb_%d", i);
		IniWrite(file,name,L"name",limbs[i]->name);

		swprintf(string, L"%d", limbs[i]->firstchain);
		IniWrite(file,name,L"first",string);

		swprintf(string, L"%d", limbs[i]->lastchain);
		IniWrite(file,name,L"last",string);
	}


	//-------

	MessageBox(0,L"Конфигурация успешно сохранена!", L"Сохранение", 0);

	return S_OK;
}
예제 #6
0
파일: Rename.cpp 프로젝트: HeIIoween/FLHook
	bool UserCmd_RenameMe(uint iClientID, const wstring &wscCmd, const wstring &wscParam, const wchar_t *usage)
	{
		HK_ERROR err;

		// Don't indicate an error if moving is disabled.
		if (!set_bEnableRenameMe)
			return false;

		// Indicate an error if the command does not appear to be formatted correctly 
		// and stop processing but tell FLHook that we processed the command.
		if (wscParam.size()==0)
		{
			PrintUserCmdText(iClientID, L"ERR Invalid parameters");
			PrintUserCmdText(iClientID, usage);
			return true;
		}

		uint iBaseID;
		pub::Player::GetBase(iClientID, iBaseID);
		if (!iBaseID)
		{
			PrintUserCmdText(iClientID, L"ERR Not in base");
			return true;
		}

		// If the new name contains spaces then flag this as an
		// error.
		wstring wscNewCharname = Trim(GetParam(wscParam, L' ', 0));

		// Get the character name for this connection.
		wstring wscCharname = (const wchar_t*)Players.GetActiveCharacterName(iClientID);

		for (map<wstring, LockedShipsStruct>::iterator i = MapLockedShips.begin(); i != MapLockedShips.end(); ++i)
		{
			if ((i->first == wscCharname) && (i->second.LockLevel > 0))
			{
				PrintUserCmdText(iClientID, L"ERR This ship is locked. The FBI has been notified.");
				wstring spurdoip;
				HkGetPlayerIP(iClientID, spurdoip);
				AddLog("SHIPLOCK: Attempt to rename locked ship %s from IP %s", wstos(wscCharname).c_str(), wstos(spurdoip).c_str());
				ConPrint(L"SHIPLOCK: Attempt to rename locked ship %s from IP %s\n", wscCharname.c_str(), spurdoip.c_str());
				return true;
			}
		}

		if (wscNewCharname.find(L" ")!=-1)
		{
			PrintUserCmdText(iClientID, L"ERR Space characters not allowed in name");
			return true;
		}

		if (HkGetAccountByCharname(wscNewCharname))
		{
			PrintUserCmdText(iClientID, L"ERR Name already exists");	
			return true;
		}

		if (wscNewCharname.length() > 23)
		{
			PrintUserCmdText(iClientID, L"ERR Name to long");	
			return true;
		}
		
		if (wscNewCharname.length() < MIN_CHAR_TAG_LEN)
		{
			PrintUserCmdText(iClientID, L"ERR Name to short");	
			return true;
		}

		if (set_bCharnameTags)
		{
			wstring wscPassword = Trim(GetParam(wscParam, L' ', 1));

			for (std::map<wstring, TAG_DATA>::iterator i = mapTagToPassword.begin(); i != mapTagToPassword.end(); ++i)
			{
				if (wscNewCharname.find(i->first)==0
					&& i->second.rename_password.size() != 0)
				{
					if (!wscPassword.length())
					{
						PrintUserCmdText(iClientID, L"ERR Name starts with an owned tag. Password is required.");	
						return true;
					}
					else if (wscPassword != i->second.master_password
						&& wscPassword != i->second.rename_password)
					{
						PrintUserCmdText(iClientID, L"ERR Name starts with an owned tag. Password is wrong.");	
						return true;
					}
					// Password is valid for owned tag.
					break;
				}
			}
		}

		// Saving the characters forces an anti-cheat checks and fixes 
		// up a multitude of other problems.
		HkSaveChar(wscCharname);
		if (!HkIsValidClientID(iClientID))
			return true;

		// Read the current number of credits for the player
		// and check that the character has enough cash.
		int iCash = 0;
		if ((err = HkGetCash(wscCharname, iCash)) != HKE_OK)
		{
			PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err));
			return true;
		}
		if (set_iRenameCost>0 && iCash<set_iRenameCost)
		{
			PrintUserCmdText(iClientID, L"ERR Insufficient credits");
			return true;
		}

		// Read the last time a rename was done on this character
		wstring wscDir;
		if ((err = HkGetAccountDirName(wscCharname, wscDir))!=HKE_OK)
		{
			PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err));
			return true;
		}
		string scRenameFile  = scAcctPath + wstos(wscDir) + "\\" + "rename.ini";
		int lastRenameTime = IniGetI(scRenameFile, "General", wstos(wscCharname), 0);

		// If a rename was done recently by this player then reject the request.
		// I know that time() returns time_t...shouldn't matter for a few years
		// yet.
		if ((lastRenameTime + 300) < (int)time(0))
		{
			if ((lastRenameTime + set_iRenameTimeLimit) > (int)time(0))
			{
				PrintUserCmdText(iClientID, L"ERR Rename time limit");
				return true;
			}
		}

		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scAcctPath = string(szDataPath) + "\\Accts\\MultiPlayer\\";

		wstring wscSourceFile;
		if ((err = HkGetCharFileName(wscCharname, wscSourceFile))!=HKE_OK)
		{
			PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err));
			return true;
		}
		wstring wscDestFile;
		if ((err = HkGetCharFileName(wscNewCharname, wscDestFile))!=HKE_OK)
		{
			PrintUserCmdText(iClientID, L"ERR "+HkErrGetText(err));
			return true;
		}

		// Remove cash if we're charging for it.
		if (set_iRenameCost>0)
			HkAddCash(wscCharname, 0-set_iRenameCost);


		RENAME o;
		o.wscCharname = wscCharname;
		o.wscNewCharname = wscNewCharname;
		o.scSourceFile = scAcctPath + wstos(wscDir) + "\\" + wstos(wscSourceFile) + ".fl";
		o.scDestFile = scAcctPath + wstos(wscDir) + "\\" + wstos(wscDestFile) + ".fl";
		o.scDestFileTemp = scAcctPath + wstos(wscDir) + "\\" + wstos(wscSourceFile) + ".fl.renaming";
		pendingRenames.push_back(o);
		
		HkKickReason(o.wscCharname, L"Updating character, please wait 10 seconds before reconnecting");
		IniWrite(scRenameFile, "General", wstos(o.wscNewCharname), itos((int)time(0)));
		return true;
	}