ok bin mitlerweile von alleine… ähm ok fast alleine drauf gekommen^^
das hier,
Autobuy in version 1.6.0
« on: November 19, 2008, 03:01:48 pm »
Reply with quoteQuote
Has any else had problems using the autobuy command with flhook plugin 1.6.0 - I think it is broken?
During the base docking process, items are automatically bought and added to the player’s ship but the player gets kicked when this happens. The “flserver-errors.log” file contains an entry like:
1: E:\FL\Scratch\Source\Server\gf\BaseDB.cpp(1645) : *** ERROR: Location 0 is invalid
Looking at the code, BaseEnter() calls HkPlayerAutoBuy() which calls HkAddCargo(). HkAddCargo() uses a base/location exit/enter trick to deal with the flserver cheat detection but the location isn’t valid when the BaseEnter function is called.
I tried the following modification in HkAddCargo() and it seemed to fix the problem…I’m not sure it does but it works for a few simple test cases I tried.
if(iBase) {
if(iLocation) // ADDED THIS CHECK
Server.LocationExit(iLocation,iClientID);
Server.BaseExit(iBase,iClientID);
if(!HkIsValidClientID(iClientID)) // got cheat kicked
return HKE_PLAYER_NOT_LOGGED_IN;
}
and
if(iBase) {
Server.BaseEnter(iBase, iClientID);
if(iLocation) // ADDED THIS CHECK
Server.LocationEnter(iLocation, iClientID);
```}
und die übernahme des volgenden Codes aus der 1.5.9 konnte das Problem beheben
HK_ERROR HkAddCargo(wstring wscCharname, uint iGoodID, int iCount, bool bMission)
{
HK_GET_CLIENTID(iClientID, wscCharname);
if(iClientID == -1 || HkIsInCharSelectMenu(iClientID))
return HKE_PLAYER_NOT_LOGGED_IN;
// anti-cheat related
char *szClassPtr;
memcpy(&szClassPtr, &Players, 4);
szClassPtr += 0x418 * (iClientID - 1);
EquipDescList *edlList = (EquipDescList*)szClassPtr + 0x328;
bool bCargoFound = true;
if(!edlList->find_matching_cargo(iGoodID, 0, 1))
bCargoFound = false;
// add
const GoodInfo *gi;
if(!(gi = GoodList::find_by_id(iGoodID)))
return HKE_INVALID_GOOD;
bool bMultiCount;
memcpy(&bMultiCount, (char*)gi + 0x70, 1);
if(bMultiCount) { // it's a good that can have multiple units(commodities, missile ammo, etc)
int iRet;
// we need to do this, else server or client may crash
list <cargo_info>lstCargo;
HkEnumCargo(wscCharname, lstCargo, iRet);
foreach(lstCargo, CARGO_INFO, it)
{
if(((*it).iArchID == iGoodID) && ((*it).bMission != bMission))
{
HkRemoveCargo(wscCharname, (*it).iID, (*it).iCount);
iCount += (*it).iCount;
}
}
pub::Player::AddCargo(iClientID, iGoodID, iCount, 1, bMission);
} else {
for(int i = 0; (i < iCount); i++)
pub::Player::AddCargo(iClientID, iGoodID, 1, 1, bMission);
}
uint iBase = 0;
pub::Player::GetBase(iClientID, iBase);
if(iBase)
{ // player docked on base
///////////////////////////////////////////////////
// fix, else we get anti-cheat msg when undocking
// this DOES NOT disable anti-cheat-detection, we're
// just making some adjustments so that we dont get kicked
// fix "Ship or Equipment not sold on base" kick
if(!bCargoFound)
{
// get last equipid
char *szLastEquipID = szClassPtr + 0x3C8;
ushort sEquipID;
memcpy(&sEquipID, szLastEquipID, 2);
// add to check-list which is being compared to the users equip-list when saving char
EquipDesc ed;
memset(&ed, 0, sizeof(ed));
ed.id = sEquipID;
ed.count = iCount;
ed.archid = iGoodID;
edlList->add_equipment_item(ed, true);
}
// fix "Ship Related" kick, update crc
ulong lCRC;
__asm
{
mov ecx, [szClassPtr]
call [CRCAntiCheat]
mov [lCRC], eax
}
memcpy(szClassPtr + 0x320, &lCRC, 4);
}</cargo_info>
grüsse,
Andi