Example #1
0
DLLFUNC bool LoadSkillCaps(CALLBACK_DBLoadSkillCaps cb, int32 opsize, int8 ClassCount, int8 SkillCount, int8 LevelCount) {
	if(opsize != sizeof(uint16)) {
		cout << "Error: EMuShareMem: DLLLoadSkillCaps: opsize != sizeof(uint16)" << endl;
		cout << "SkillCap size has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	int32 tmpMemSize = sizeof(MMFSkillCaps_Struct) + opsize * (ClassCount*SkillCount*LevelCount);
	if (SkillCapsMMF.Open("EQEMuKSkillCaps", tmpMemSize)) {
		if (SkillCapsMMF.CanWrite()) {
			MMFSkillCapsData_Writable = (MMFSkillCaps_Struct*) SkillCapsMMF.GetWriteableHandle();
			if (!MMFSkillCapsData_Writable) {
				cout << "Error: EMuShareMem: DLLLoadSkillCaps: !MMFSkillCapsData_Writable" << endl;
				return false;
			}
			//we need to memset the eq SkillCaps
			memset(MMFSkillCapsData_Writable->caps, 0, sizeof(uint16)*(ClassCount*SkillCount*LevelCount));
			
			MMFSkillCapsData_Writable->ClassCount = ClassCount;
			MMFSkillCapsData_Writable->SkillCount = SkillCount;
			MMFSkillCapsData_Writable->LevelCount = LevelCount;
			// use a callback so the DB functions are done in the main exe
			// this way the DLL doesnt have to open a connection to mysql
			if (!cb()) {
				cout << "Error: EMuShareMem: DLLLoadSkillCaps: !cbDBLoadSkillCaps" << endl;
				return false;
			}
			
			MMFSkillCapsData_Writable = 0;
			
			SkillCapsMMF.SetLoaded();
			MMFSkillCapsData = (const MMFSkillCaps_Struct*) SkillCapsMMF.GetHandle();
			if (!MMFSkillCapsData) {
				cout << "Error: EMuShareMem: DLLLoadSkillCaps: !MMFSkillCapsData (CanWrite=true)" << endl;
				return false;
			}
			return true;
		} else {
			if (!SkillCapsMMF.IsLoaded()) {
				Timer::SetCurrentTime();
				int32 starttime = Timer::GetCurrentTime();
				while ((!SkillCapsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
					Sleep(10);
					Timer::SetCurrentTime();
				}
				if (!SkillCapsMMF.IsLoaded()) {
					cout << "Error: EMuShareMem: DLLLoadSkillCaps: !SkillCapsMMF.IsLoaded() (timeout)" << endl;
					return false;
				}
			}
			MMFSkillCapsData = (const MMFSkillCaps_Struct*) SkillCapsMMF.GetHandle();
			if (!MMFSkillCapsData) {
				cout << "Error: EMuShareMem: DLLLoadSkillCaps: !MMFSkillCapsData (CanWrite=false)" << endl;
				return false;
			}
			
			return true;
		}
	}
	else {
		cout << "Error Loading SkillCaps: SkillCaps.cpp: pDLLLoadSkillCaps: ret == 0, size = " << tmpMemSize << endl;
		return false;
	}
	return false;
}
Example #2
0
bool pDLLLoadNPCFactionLists(CALLBACK_DBLoadNPCFactionLists cbDBLoadNPCFactionLists, uint32 iNPCFactionListStructSize, int32* iNPCFactionListsCount, uint32* iMaxNPCFactionListID, uint8 iMaxNPCFactions) {
	if (iNPCFactionListStructSize != sizeof(NPCFactionList)) {
		cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: iNPCFactionListStructSize != sizeof(NPCFactionList)" << endl;
		cout << "NPCFactionList struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	if (iMaxNPCFactions != MAX_NPC_FACTIONS) {
		cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: iMaxNPCFactions != MAX_NPC_FACTIONS" << endl;
		cout << "NPCFactionList struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	if (*iMaxNPCFactionListID > MMF_MAX_NPCFactionList_ID) {
		cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: iMaxNPCFactions > MMF_MAX_NPCFactionList_ID" << endl;
		cout << "You need to increase the define in NPCFactionList.h." << endl;
		return false;
	}
	uint32 tmpMemSize = sizeof(MMFNPCFactionLists_Struct) + 256 + (sizeof(NPCFactionList) * (*iNPCFactionListsCount));
	if (NPCFactionListsMMF.Open("EQEMuFactionLists", tmpMemSize)) {
//		MMFNPCFactionListsData = (const MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetHandle();
		if (NPCFactionListsMMF.CanWrite()) {
			MMFNPCFactionListsData_Writable = (MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetWriteableHandle();
			if (!MMFNPCFactionListsData_Writable) {
				cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !MMFNPCFactionListsData_Writable" << endl;
				return false;
			}

			memset(MMFNPCFactionListsData_Writable, 0, tmpMemSize);
			for(int i=0; i<MMF_MAX_NPCFactionList_ID; i++)
				MMFNPCFactionListsData_Writable->NPCFactionListIndex[i] = 0xFFFFFFFF;
			MMFNPCFactionListsData_Writable->MaxNPCFactionListID = *iMaxNPCFactionListID;
			MMFNPCFactionListsData_Writable->NPCFactionListCount = *iNPCFactionListsCount;
			// use a callback so the DB functions are done in the main exe
			// this way the DLL doesnt have to open a connection to mysql
			if (!cbDBLoadNPCFactionLists(MMFNPCFactionListsData_Writable->NPCFactionListCount, MMFNPCFactionListsData_Writable->MaxNPCFactionListID)) {
				cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !cbDBLoadNPCFactionLists" << endl;
				return false;
			}

			MMFNPCFactionListsData_Writable = 0;
			NPCFactionListsMMF.SetLoaded();
			MMFNPCFactionListsData = (const MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetHandle();
			if (!MMFNPCFactionListsData) {
				cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !MMFNPCFactionListsData (CanWrite=true)" << endl;
				return false;
			}
			return true;
		}
		else {
			if (!NPCFactionListsMMF.IsLoaded()) {
				Timer::SetCurrentTime();
				uint32 starttime = Timer::GetCurrentTime();
				while ((!NPCFactionListsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
					Sleep(100);
					Timer::SetCurrentTime();
				}
				if (!NPCFactionListsMMF.IsLoaded()) {
					cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !NPCFactionListsMMF.IsLoaded() (timeout)" << endl;
					return false;
				}
			}
			MMFNPCFactionListsData = (const MMFNPCFactionLists_Struct*) NPCFactionListsMMF.GetHandle();
			if (!MMFNPCFactionListsData) {
				cout << "Error: EMuShareMem: DLLLoadNPCFactionLists: !MMFNPCFactionListsData (CanWrite=false)" << endl;
				return false;
			}
			*iMaxNPCFactionListID = MMFNPCFactionListsData->MaxNPCFactionListID;
			*iNPCFactionListsCount = MMFNPCFactionListsData->NPCFactionListCount;
			return true;
		}
	}
	else {
		cout << "Error Loading NPCFactionLists: NPCFactionLists.cpp: pDLLLoadNPCFactionLists: Open() == false" << endl;
		return false;
	}
	return false;
};
Example #3
0
bool pDLLLoadDoors(CALLBACK_DBLoadDoors cbDBLoadDoors, uint32 iDoorstructSize, int32* iDoorsCount, uint32* iMaxDoorID) {
	if (iDoorstructSize != sizeof(Door)) {
		cout << "Error: EMuShareMem: DLLLoadDoors: iDoorstructSize != sizeof(Door)" << endl;
		cout << "Door struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	if (*iMaxDoorID > MMF_MAX_Door_ID) {
		cout << "Error: EMuShareMem: pDLLLoadDoors: iMaxDoorID > MMF_MAX_Door_ID" << endl;
		cout << "You need to increase the define in Doors.h." << endl;
		return false;
	}
	uint32 tmpMemSize = sizeof(MMFDoors_Struct) + 256 + (sizeof(Door) * (*iDoorsCount));
	if (DoorsMMF.Open("EQEMuDoors", tmpMemSize)) {
		if (DoorsMMF.CanWrite()) {
			MMFDoorsData_Writable = (MMFDoors_Struct*) DoorsMMF.GetWriteableHandle();
			if (!MMFDoorsData_Writable) {
				cout << "Error: EMuShareMem: DLLLoadDoors: !MMFDoorsData_Writable" << endl;
				return false;
			}

			memset(MMFDoorsData_Writable, 0, tmpMemSize);
			for(int i=0; i<MMF_MAX_Door_ID; i++)
				MMFDoorsData_Writable->DoorIndex[i] = 0xFFFFFFFF;
			MMFDoorsData_Writable->MaxDoorID = *iMaxDoorID;
			MMFDoorsData_Writable->DoorCount = *iDoorsCount;
			// use a callback so the DB functions are done in the main exe
			// this way the DLL doesnt have to open a connection to mysql
			if (!cbDBLoadDoors(*iDoorsCount, *iMaxDoorID)) {
				cout << "Error: EMuShareMem: DLLLoadDoors: !cbDBLoadDoors" << endl;
				return false;
			}

			MMFDoorsData_Writable = 0;
			DoorsMMF.SetLoaded();
			MMFDoorsData = (const MMFDoors_Struct*) DoorsMMF.GetHandle();
			if (!MMFDoorsData) {
				cout << "Error: EMuShareMem: DLLLoadDoors: !MMFDoorsData (CanWrite=true)" << endl;
				return false;
			}
			return true;
		}
		else {
			if (!DoorsMMF.IsLoaded()) {
				Timer::SetCurrentTime();
				uint32 starttime = Timer::GetCurrentTime();
				while ((!DoorsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
					Sleep(10);
					Timer::SetCurrentTime();
				}
				if (!DoorsMMF.IsLoaded()) {
					cout << "Error: EMuShareMem: DLLLoadDoors: !DoorsMMF.IsLoaded() (timeout)" << endl;
					return false;
				}
			}
			MMFDoorsData = (const MMFDoors_Struct*) DoorsMMF.GetHandle();
			if (!MMFDoorsData) {
				cout << "Error: EMuShareMem: DLLLoadDoors: !MMFDoorsData (CanWrite=false)" << endl;
				return false;
			}
			*iMaxDoorID = MMFDoorsData->MaxDoorID;
			*iDoorsCount = MMFDoorsData->DoorCount;
			return true;
		}
	}
	else {
		cout << "Error Loading Doors: Doors.cpp: pDLLLoadDoors: ret == 0" << endl;
		return false;
	}
	return false;
};
Example #4
0
DLLFUNC bool DLLLoadItems(CALLBACK_DBLoadItems cbDBLoadItems, uint32 iItemStructSize, int32* iItemCount, uint32* iMaxItemID) {
    if (iItemStructSize != sizeof(Item_Struct)) {
        cout << "Error: EMuShareMem: DLLLoadItems: iItemStructSize != sizeof(Item_Struct)" << endl;
        cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
        return false;
    }
    if (*iMaxItemID > MMF_EQMAX_ITEMS) {
        cout << "Error: EMuShareMem: pDLLLoadItems: iMaxItemID > MMF_EQMAX_ITEMS" << endl;
        cout << "You need to increase the define in Items.h." << endl;
        return false;
    }

    MMFItemsData_Writable = 0;
    //Allocate the shared memory for the item structures
    uint32 tmpMemSize = sizeof(MMFItems_Struct) + 256 + (sizeof(Item_Struct) * (*iItemCount));
    //cout << tmpMemSize << endl;
    if (ItemsMMF.Open("EQEMuItems", tmpMemSize)) {
        if (ItemsMMF.CanWrite()) {
            MMFItemsData_Writable = (MMFItems_Struct*) ItemsMMF.GetWriteableHandle();
            if (!MMFItemsData_Writable) {
                cout << "Error: EMuShareMem: DLLLoadItems: !MMFItemsData_Writable" << endl;
                return false;
            }

            memset(MMFItemsData_Writable, 0, tmpMemSize);
            for(int i=0; i<MMF_EQMAX_ITEMS; i++)
                MMFItemsData_Writable->ItemIndex[i] = 0xFFFF;
            MMFItemsData_Writable->MaxItemID = *iMaxItemID;
            MMFItemsData_Writable->ItemCount = *iItemCount;
            //the writable handle has been created, do the load below after we have the
            //serialization handle as well.
        } else {
            if (!ItemsMMF.IsLoaded()) {
                Timer::SetCurrentTime();
                uint32 starttime = Timer::GetCurrentTime();
                while ((!ItemsMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
                    Sleep(10);
                    Timer::SetCurrentTime();
                }
                if (!ItemsMMF.IsLoaded()) {
                    cout << "Error: EMuShareMem: DLLLoadItems: !ItemsMMF.IsLoaded() (timeout)" << endl;
                    return false;
                }
            }
            MMFItemsData = (const MMFItems_Struct*) ItemsMMF.GetHandle();
            if (!MMFItemsData) {
                cout << "Error: EMuShareMem: DLLLoadItems: !MMFItemsData (CanWrite=false)" << endl;
                return false;
            }
            *iMaxItemID = MMFItemsData->MaxItemID;
            *iItemCount = MMFItemsData->ItemCount;

            return true;
        }
    } else {
        cout << "Error Loading Items: Items.cpp: pDLLLoadItems: Open() == false" << endl;
        return false;
    }
    /*

    		// use a callback so the DB functions are done in the main exe
    		// this way the DLL doesnt have to open a connection to mysql
    		if (!cbDBLoadItems(*iItemCount, *iMaxItemID)) {
    			cout << "Error: EMuShareMem: DLLLoadItems: !cbDBLoadItems" << endl;
    			return false;
    		}

    */

    // use a callback so the DB functions are done in the main exe
    // this way the DLL doesnt have to open a connection to mysql
    if (!cbDBLoadItems(*iItemCount, *iMaxItemID)) {
        cout << "Error: EMuShareMem: DLLLoadItems: !cbDBLoadItems" << endl;
        return false;
    }


    //Now, Disable the write handle and get the read handle.
    //do this for both item struct and serialization data

    MMFItemsData_Writable = 0;
    ItemsMMF.SetLoaded();
    MMFItemsData = (const MMFItems_Struct*) ItemsMMF.GetHandle();
    if (!MMFItemsData) {
        cout << "Error: EMuShareMem: DLLLoadItems: !MMFItemsData (CanWrite=true)" << endl;
        return false;
    }

    return true;
};
Example #5
0
bool pDLLLoadLoot(CALLBACK_DBLoadLoot cbDBLoadLoot, 
					 uint32 iLootTableStructsize, uint32 iLootTableCount, uint32 iMaxLootTable,
					 uint32 iLootTableEntryStructsize, uint32 iLootTableEntryCount,
					 uint32 iLootDropStructsize, uint32 iLootDropCount, uint32 iMaxLootDrop,
					 uint32 iLootDropEntryStructsize, uint32 iLootDropEntryCount
					 ) {
#if 0
cout << "iLootTableCount: " << iLootTableCount << endl;
cout << "iMaxLootTable: " << iMaxLootTable << endl;
cout << "iLootTableEntryCount: " << iLootTableEntryCount << endl;
cout << "iLootDropCount: " << iLootDropCount << endl;
cout << "iMaxLootDrop: " << iMaxLootDrop << endl;
cout << "iLootDropEntryCount: " << iLootDropEntryCount << endl;
#endif
	if (iLootTableStructsize != sizeof(LootTable_Struct)) {
		cout << "Error: EMuShareMem: DLLLoadLoot: iLootTableStructsize != sizeof(LootTable_Struct)" << endl;
		cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	if (iLootTableEntryStructsize != sizeof(LootTableEntries_Struct)) {
		cout << "Error: EMuShareMem: DLLLoadLoot: iLootTableEntryStructsize != sizeof(LootTableEntries_Struct)" << endl;
		cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	if (iLootDropStructsize != sizeof(LootDrop_Struct)) {
		cout << "Error: EMuShareMem: DLLLoadLoot: iLootDropStructsize != sizeof(LootDrop_Struct)" << endl;
		cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}
	if (iLootDropEntryStructsize != sizeof(LootDropEntries_Struct)) {
		cout << "Error: EMuShareMem: DLLLoadLoot: iLootDropEntryStructsize != sizeof(LootDropEntries_Struct)" << endl;
		cout << "Item_Struct has changed, EMuShareMem.dll needs to be recompiled." << endl;
		return false;
	}

	uint32 tmpMemSize = sizeof(MMFLoot_Struct) + 256
		+ (sizeof(uint32) * (iMaxLootTable+1))
		+ (sizeof(LootTable_Struct) * iLootTableCount) + (sizeof(LootTableEntries_Struct) * iLootTableEntryCount)
		+ (sizeof(uint32) * (iMaxLootDrop+1))
		+ (sizeof(LootDrop_Struct) * iLootDropCount) + (sizeof(LootDropEntries_Struct) * iLootDropEntryCount)
		;
	if (LootMMF.Open("EQEMuLoot", tmpMemSize)) {
		if (LootMMF.CanWrite()) {
			MMFLootData_Writable = (MMFLoot_Struct*) LootMMF.GetWriteableHandle();
			if (!MMFLootData_Writable) {
				cout << "Error: EMuShareMem: DLLLoadLoot: !MMFLootData_Writable" << endl;
				return false;
			}

			memset(MMFLootData_Writable, 0, tmpMemSize);
			MMFLootData_Writable->LootTableCount = iLootTableCount;
			MMFLootData_Writable->MaxLootTableID = iMaxLootTable;
			MMFLootData_Writable->LootDropCount = iLootDropCount;
			MMFLootData_Writable->MaxLootDropID = iMaxLootDrop;
			MMFLootData_Writable->datamax = tmpMemSize - sizeof(MMFLoot_Struct);

			MMFLootData_Writable->dataindex = 0;
			MMFLootData_Writable->LootTableOffset = MMFLootData_Writable->dataindex;
			MMFLootData_Writable->dataindex += (sizeof(uint32) * (iMaxLootTable+1));
			MMFLootData_Writable->LootDropOffset = MMFLootData_Writable->dataindex;
			MMFLootData_Writable->dataindex += (sizeof(uint32) * (iMaxLootDrop+1));

			LootTable = (uint32*) &MMFLootData_Writable->data[MMFLootData_Writable->LootTableOffset];
			LootDrop = (uint32*) &MMFLootData_Writable->data[MMFLootData_Writable->LootDropOffset];

			// use a callback so the DB functions are done in the main exe
			// this way the DLL doesnt have to open a connection to mysql
			if (!cbDBLoadLoot()) {
				cout << "Error: EMuShareMem: DLLLoadLoot: !cbDBLoadLoot" << endl;
				return false;
			}

			MMFLootData_Writable = 0;
			LootMMF.SetLoaded();
		}
		else {
			if (!LootMMF.IsLoaded()) {
				Timer::SetCurrentTime();
				uint32 starttime = Timer::GetCurrentTime();
				while ((!LootMMF.IsLoaded()) && ((Timer::GetCurrentTime() - starttime) < 300000)) {
					Sleep(10);
					Timer::SetCurrentTime();
				}
				if (!LootMMF.IsLoaded()) {
					cout << "Error: EMuShareMem: DLLLoadLoot: !LootMMF.IsLoaded() (timeout)" << endl;
					return false;
				}
			}
		}
	}
	else {
		cout << "Error Loading Loot: Loot.cpp: pDLLLoadLoot: Open() == false" << endl;
		return false;
	}
	MMFLootData = (const MMFLoot_Struct*) LootMMF.GetHandle();
	if (!MMFLootData) {
		cout << "Error: EMuShareMem: DLLLoadLoot: !MMFLootData" << endl;
		MMFLootData = 0;
		return false;
	}
	if (MMFLootData->LootTableCount != iLootTableCount
		|| MMFLootData->MaxLootTableID != iMaxLootTable
		|| MMFLootData->LootDropCount != iLootDropCount
		|| MMFLootData->MaxLootDropID != iMaxLootDrop) {
		cout << "Error: EMuShareMem: DLLLoadLoot: Count/Max mismatch" << endl;
		MMFLootData = 0;
		return false;
	}
	LootTable = (uint32*) &MMFLootData->data[MMFLootData->LootTableOffset];
	LootDrop = (uint32*) &MMFLootData->data[MMFLootData->LootDropOffset];
	return true;
};