mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Make dynamic IDs count down from max instead of up from 0
This commit is contained in:
parent
91dd5d5280
commit
dd3066849b
@ -275,7 +275,7 @@ void Chunking::createInstance(uint64_t instanceID) {
|
|||||||
continue; // follower; don't copy individually
|
continue; // follower; don't copy individually
|
||||||
|
|
||||||
Mob* newMob = new Mob(baseNPC->x, baseNPC->y, baseNPC->z, baseNPC->appearanceData.iAngle,
|
Mob* newMob = new Mob(baseNPC->x, baseNPC->y, baseNPC->z, baseNPC->appearanceData.iAngle,
|
||||||
instanceID, baseNPC->appearanceData.iNPCType, NPCManager::NPCData[baseNPC->appearanceData.iNPCType], NPCManager::nextId++);
|
instanceID, baseNPC->appearanceData.iNPCType, NPCManager::NPCData[baseNPC->appearanceData.iNPCType], NPCManager::nextId--);
|
||||||
NPCManager::NPCs[newMob->appearanceData.iNPC_ID] = newMob;
|
NPCManager::NPCs[newMob->appearanceData.iNPC_ID] = newMob;
|
||||||
|
|
||||||
// if in a group, copy over group members as well
|
// if in a group, copy over group members as well
|
||||||
@ -284,7 +284,7 @@ void Chunking::createInstance(uint64_t instanceID) {
|
|||||||
Mob* mobData = (Mob*)baseNPC;
|
Mob* mobData = (Mob*)baseNPC;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (mobData->groupMember[i] != 0) {
|
if (mobData->groupMember[i] != 0) {
|
||||||
int followerID = NPCManager::nextId++; // id for follower
|
int followerID = NPCManager::nextId--; // id for follower
|
||||||
BaseNPC* baseFollower = NPCManager::NPCs[mobData->groupMember[i]]; // follower from template
|
BaseNPC* baseFollower = NPCManager::NPCs[mobData->groupMember[i]]; // follower from template
|
||||||
// new follower instance
|
// new follower instance
|
||||||
Mob* newMobFollower = new Mob(baseFollower->x, baseFollower->y, baseFollower->z, baseFollower->appearanceData.iAngle,
|
Mob* newMobFollower = new Mob(baseFollower->x, baseFollower->y, baseFollower->z, baseFollower->appearanceData.iAngle,
|
||||||
@ -306,7 +306,7 @@ void Chunking::createInstance(uint64_t instanceID) {
|
|||||||
instanceID, baseNPC->appearanceData.iAngle);
|
instanceID, baseNPC->appearanceData.iAngle);
|
||||||
} else {
|
} else {
|
||||||
BaseNPC* newNPC = new BaseNPC(baseNPC->x, baseNPC->y, baseNPC->z, baseNPC->appearanceData.iAngle,
|
BaseNPC* newNPC = new BaseNPC(baseNPC->x, baseNPC->y, baseNPC->z, baseNPC->appearanceData.iAngle,
|
||||||
instanceID, baseNPC->appearanceData.iNPCType, NPCManager::nextId++);
|
instanceID, baseNPC->appearanceData.iNPCType, NPCManager::nextId--);
|
||||||
NPCManager::NPCs[newNPC->appearanceData.iNPC_ID] = newNPC;
|
NPCManager::NPCs[newNPC->appearanceData.iNPC_ID] = newNPC;
|
||||||
NPCManager::updateNPCPosition(newNPC->appearanceData.iNPC_ID, baseNPC->x, baseNPC->y, baseNPC->z,
|
NPCManager::updateNPCPosition(newNPC->appearanceData.iNPC_ID, baseNPC->x, baseNPC->y, baseNPC->z,
|
||||||
instanceID, baseNPC->appearanceData.iAngle);
|
instanceID, baseNPC->appearanceData.iAngle);
|
||||||
|
@ -512,8 +512,8 @@ static void eggCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(NPCManager::nextId < INT32_MAX);
|
//assert(NPCManager::nextId < INT32_MAX);
|
||||||
int id = NPCManager::nextId++;
|
int id = NPCManager::nextId--;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type,
|
|||||||
uint64_t inst = baseInstance ? MAPNUM(instance) : instance;
|
uint64_t inst = baseInstance ? MAPNUM(instance) : instance;
|
||||||
#define EXTRA_HEIGHT 0
|
#define EXTRA_HEIGHT 0
|
||||||
|
|
||||||
assert(nextId < INT32_MAX);
|
//assert(nextId < INT32_MAX);
|
||||||
int id = nextId++;
|
int id = nextId--;
|
||||||
int team = NPCData[type]["m_iTeam"];
|
int team = NPCData[type]["m_iTeam"];
|
||||||
BaseNPC *npc = nullptr;
|
BaseNPC *npc = nullptr;
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ static void loadPaths(int* nextId) {
|
|||||||
if (passedDistance >= SLIDER_GAP_SIZE) { // space them out uniformaly
|
if (passedDistance >= SLIDER_GAP_SIZE) { // space them out uniformaly
|
||||||
passedDistance -= SLIDER_GAP_SIZE; // step down
|
passedDistance -= SLIDER_GAP_SIZE; // step down
|
||||||
// spawn a slider
|
// spawn a slider
|
||||||
Bus* slider = new Bus(point.x, point.y, point.z, 0, INSTANCE_OVERWORLD, 1, (*nextId)++);
|
Bus* slider = new Bus(point.x, point.y, point.z, 0, INSTANCE_OVERWORLD, 1, (*nextId)--);
|
||||||
NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider;
|
NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider;
|
||||||
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->x, slider->y, slider->z, INSTANCE_OVERWORLD, 0);
|
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->x, slider->y, slider->z, INSTANCE_OVERWORLD, 0);
|
||||||
Transport::NPCQueues[slider->appearanceData.iNPC_ID] = route;
|
Transport::NPCQueues[slider->appearanceData.iNPC_ID] = route;
|
||||||
@ -484,7 +484,7 @@ static void loadEggs(int32_t* nextId) {
|
|||||||
int eggCount = 0;
|
int eggCount = 0;
|
||||||
for (auto _egg = eggs.begin(); _egg != eggs.end(); _egg++) {
|
for (auto _egg = eggs.begin(); _egg != eggs.end(); _egg++) {
|
||||||
auto egg = _egg.value();
|
auto egg = _egg.value();
|
||||||
int id = (*nextId)++;
|
int id = (*nextId)--;
|
||||||
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
||||||
|
|
||||||
Egg* addEgg = new Egg((int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, (int)egg["iType"], id, false);
|
Egg* addEgg = new Egg((int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, (int)egg["iType"], id, false);
|
||||||
@ -560,7 +560,7 @@ static void loadGruntwork(int32_t *nextId) {
|
|||||||
for (auto _mob = mobs.begin(); _mob != mobs.end(); _mob++) {
|
for (auto _mob = mobs.begin(); _mob != mobs.end(); _mob++) {
|
||||||
auto mob = _mob.value();
|
auto mob = _mob.value();
|
||||||
BaseNPC *npc;
|
BaseNPC *npc;
|
||||||
int id = (*nextId)++;
|
int id = (*nextId)--;
|
||||||
uint64_t instanceID = mob.find("iMapNum") == mob.end() ? INSTANCE_OVERWORLD : (int)mob["iMapNum"];
|
uint64_t instanceID = mob.find("iMapNum") == mob.end() ? INSTANCE_OVERWORLD : (int)mob["iMapNum"];
|
||||||
|
|
||||||
if (NPCManager::NPCData[(int)mob["iNPCType"]]["m_iTeam"] == 2) {
|
if (NPCManager::NPCData[(int)mob["iNPCType"]]["m_iTeam"] == 2) {
|
||||||
@ -595,7 +595,7 @@ static void loadGruntwork(int32_t *nextId) {
|
|||||||
|
|
||||||
tmp->groupLeader = *nextId;
|
tmp->groupLeader = *nextId;
|
||||||
|
|
||||||
(*nextId)++;
|
(*nextId)--;
|
||||||
|
|
||||||
auto followers = leader["aFollowers"];
|
auto followers = leader["aFollowers"];
|
||||||
if (followers.size() < 5) {
|
if (followers.size() < 5) {
|
||||||
@ -616,7 +616,7 @@ static void loadGruntwork(int32_t *nextId) {
|
|||||||
tmpFol->groupLeader = tmp->appearanceData.iNPC_ID;
|
tmpFol->groupLeader = tmp->appearanceData.iNPC_ID;
|
||||||
tmp->groupMember[followerCount++] = *nextId;
|
tmp->groupMember[followerCount++] = *nextId;
|
||||||
|
|
||||||
(*nextId)++;
|
(*nextId)--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -629,7 +629,7 @@ static void loadGruntwork(int32_t *nextId) {
|
|||||||
auto eggs = gruntwork["eggs"];
|
auto eggs = gruntwork["eggs"];
|
||||||
for (auto _egg = eggs.begin(); _egg != eggs.end(); _egg++) {
|
for (auto _egg = eggs.begin(); _egg != eggs.end(); _egg++) {
|
||||||
auto egg = _egg.value();
|
auto egg = _egg.value();
|
||||||
int id = (*nextId)++;
|
int id = (*nextId)--;
|
||||||
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
||||||
|
|
||||||
Egg* addEgg = new Egg((int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, (int)egg["iType"], id, false);
|
Egg* addEgg = new Egg((int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, (int)egg["iType"], id, false);
|
||||||
@ -648,7 +648,7 @@ static void loadGruntwork(int32_t *nextId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TableData::init() {
|
void TableData::init() {
|
||||||
int32_t nextId = 0;
|
int32_t nextId = INT32_MAX; // next dynamic ID to hand out
|
||||||
|
|
||||||
// load NPCs from NPC.json
|
// load NPCs from NPC.json
|
||||||
try {
|
try {
|
||||||
@ -664,7 +664,7 @@ void TableData::init() {
|
|||||||
#ifdef ACADEMY
|
#ifdef ACADEMY
|
||||||
// do not spawn NPCs in the future
|
// do not spawn NPCs in the future
|
||||||
if (npc["iX"] > 512000 && npc["iY"] < 256000) {
|
if (npc["iX"] > 512000 && npc["iY"] < 256000) {
|
||||||
nextId++;
|
nextId--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -672,7 +672,7 @@ void TableData::init() {
|
|||||||
|
|
||||||
NPCManager::NPCs[nextId] = tmp;
|
NPCManager::NPCs[nextId] = tmp;
|
||||||
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
||||||
nextId++;
|
nextId--;
|
||||||
|
|
||||||
if (npc["iNPCType"] == 641 || npc["iNPCType"] == 642)
|
if (npc["iNPCType"] == 641 || npc["iNPCType"] == 642)
|
||||||
NPCManager::RespawnPoints.push_back({ npc["iX"], npc["iY"], ((int)npc["iZ"]) + RESURRECT_HEIGHT, instanceID });
|
NPCManager::RespawnPoints.push_back({ npc["iX"], npc["iY"], ((int)npc["iZ"]) + RESURRECT_HEIGHT, instanceID });
|
||||||
@ -891,7 +891,7 @@ void TableData::init() {
|
|||||||
#ifdef ACADEMY
|
#ifdef ACADEMY
|
||||||
// do not spawn NPCs in the future
|
// do not spawn NPCs in the future
|
||||||
if (npc["iX"] > 512000 && npc["iY"] < 256000) {
|
if (npc["iX"] > 512000 && npc["iY"] < 256000) {
|
||||||
nextId++;
|
nextId--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -901,7 +901,7 @@ void TableData::init() {
|
|||||||
NPCManager::NPCs[nextId] = tmp;
|
NPCManager::NPCs[nextId] = tmp;
|
||||||
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
||||||
|
|
||||||
nextId++;
|
nextId--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mob groups
|
// mob groups
|
||||||
@ -915,8 +915,8 @@ void TableData::init() {
|
|||||||
#ifdef ACADEMY
|
#ifdef ACADEMY
|
||||||
// do not spawn NPCs in the future
|
// do not spawn NPCs in the future
|
||||||
if (leader["iX"] > 512000 && leader["iY"] < 256000) {
|
if (leader["iX"] > 512000 && leader["iY"] < 256000) {
|
||||||
nextId++;
|
nextId--;
|
||||||
nextId += followers.size();
|
nextId -= followers.size();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -928,7 +928,7 @@ void TableData::init() {
|
|||||||
|
|
||||||
tmp->groupLeader = nextId;
|
tmp->groupLeader = nextId;
|
||||||
|
|
||||||
nextId++;
|
nextId--;
|
||||||
|
|
||||||
if (followers.size() < 5) {
|
if (followers.size() < 5) {
|
||||||
int followerCount = 0;
|
int followerCount = 0;
|
||||||
@ -945,7 +945,7 @@ void TableData::init() {
|
|||||||
tmpFol->groupLeader = tmp->appearanceData.iNPC_ID;
|
tmpFol->groupLeader = tmp->appearanceData.iNPC_ID;
|
||||||
tmp->groupMember[followerCount++] = nextId;
|
tmp->groupMember[followerCount++] = nextId;
|
||||||
|
|
||||||
nextId++;
|
nextId--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cout << "[WARN] Mob group leader with ID " << nextId << " has too many followers (" << followers.size() << ")\n";
|
std::cout << "[WARN] Mob group leader with ID " << nextId << " has too many followers (" << followers.size() << ")\n";
|
||||||
@ -980,7 +980,7 @@ void TableData::init() {
|
|||||||
NPCManager::NPCs[nextId] = new BaseNPC(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], instanceID, npc["iNPCType"], nextId);
|
NPCManager::NPCs[nextId] = new BaseNPC(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], instanceID, npc["iNPCType"], nextId);
|
||||||
|
|
||||||
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
||||||
nextId++;
|
nextId--;
|
||||||
|
|
||||||
if (npc["iNPCType"] == 641 || npc["iNPCType"] == 642)
|
if (npc["iNPCType"] == 641 || npc["iNPCType"] == 642)
|
||||||
NPCManager::RespawnPoints.push_back({ npc["iX"], npc["iY"], ((int)npc["iZ"]) + RESURRECT_HEIGHT, instanceID });
|
NPCManager::RespawnPoints.push_back({ npc["iX"], npc["iY"], ((int)npc["iZ"]) + RESURRECT_HEIGHT, instanceID });
|
||||||
|
Loading…
Reference in New Issue
Block a user