Untitled
unknown
plain_text
2 years ago
34 kB
5
Indexable
void join_world(ENetPeer* peer, string& name_, int spawnas_x = 0, int spawnas_y = 0, int delay = 0, bool locked = false, bool door = false) { pInfo(peer)->update = true; pInfo(peer)->autofarm = 0, pInfo(peer)->autofarm2 = 0; if (pInfo(peer)->tankIDName.empty()) return; if (not door) { if (pInfo(peer)->world_time + 1500 > (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) { gamepacket_t p; p.Insert("OnFailedToEnterWorld"), p.CreatePacket(peer); return; } pInfo(peer)->world_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count(); } if (not check_name(name_)) return cant_enter(peer, name_, door, delay); //if (door == false) wipe_beach(peer); World world_ = get_world(name_); string owner_name = world_.owner_name, user_name = (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->tankIDName); int w_c = 0, s_c = 0, net_ = 1, r_c = 0; if (world_.name != pInfo(peer)->world) { if (name_ == "CHRIS" && pInfo(peer)->tankIDName != "chris" && pInfo(peer)->tankIDName != "Vxnessa" && pInfo(peer)->tankIDName != "christine" && pInfo(peer)->tankIDName != "uzi" && pInfo(peer)->tankIDName != "Zack" && pInfo(peer)->tankIDName != "kim" && pInfo(peer)->tankIDName != "Buket" && pInfo(peer)->tankIDName != "Cyrus") return cant_enter(peer, "You are trying to enter your `2imagination ``but you `4failed.", door, delay); if (name_ == "MOD" && !pInfo(peer)->mod) return cant_enter(peer, "Only Mod able to enter this world.", door, delay); if (name_ == "VIP" && !pInfo(peer)->vip) return cant_enter(peer, "Only Vip able to enter this world.", door, delay); //if (name_ == "SUPERRAYMAN" && !pInfo(peer)->hand == 9770) return cant_enter(peer, "`9Only Golden Rayman's Fist Holder able to enter this world.", door, delay); if (world_.nuked == true && pInfo(peer)->mod + pInfo(peer)->dev < 1) return cant_enter(peer, "That world is inaccessible.", door, delay); if (pInfo(peer)->level < world_.entry_level and (world_.owner_name != pInfo(peer)->tankIDName and not pInfo(peer)->dev and not pInfo(peer)->mod)) { if (/*!guild_access(peer, world_.guild_id) and */ find(world_.admins.begin(), world_.admins.end(), user_name) == world_.admins.end()) return cant_enter(peer, "Players lower than level " + to_string(world_.entry_level) + " can't enter " + world_.name + ".", door, delay); } for (pair<string, long long int> p : world_.bannedPlayers) { if (p.first == pInfo(peer)->tankIDName) if (p.second + (3600 * 1000) > (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) return cant_enter(peer, "`4Oh no!`` You've been banned from that world by its owner! Try again later after the world ban wears off.", door, delay); } get_players(world_.name, w_c, s_c, net_, r_c); if (w_c >= 45 and not pInfo(peer)->dev and not pInfo(peer)->mod) return cant_enter(peer, "Oops, `5" + world_.name + "`` already has `445`` people in it. Try again later.", door, delay); } uint32_t ySize = 60, xSize = 100; if (world_.name == pInfo(peer)->world) { gamepacket_t p(delay, pInfo(peer)->netID), p2(delay), p3(delay, pInfo(peer)->netID); p.Insert("OnSetFreezeState"), p.Insert(1), p.CreatePacket(peer); if (spawnas_x != 0) { } else if (not locked) { for (int i_ = 0; i_ < world_.blocks.size(); i_++) { if (items.at(world_.blocks.at(i_).fg).blockType == BlockTypes::MAIN_DOOR) { spawnas_x = i_ % xSize, spawnas_y = i_ / xSize; pInfo(peer)->c_x = spawnas_x, pInfo(peer)->c_y = spawnas_y; gamepacket_t p(delay, pInfo(peer)->netID); p.Insert("SetRespawnPos"), p.Insert(i_), p.CreatePacket(peer); break; } } } else { gamepacket_t p(delay); p.Insert("OnTalkBubble"), p.Insert(pInfo(peer)->netID), p.Insert("The door is locked."), p.Insert(0), p.Insert(0), p.CreatePacket(peer); } if (not locked) { pInfo(peer)->x = spawnas_x * 32, pInfo(peer)->y = spawnas_y * 32; gamepacket_t p(delay, pInfo(peer)->netID); p.Insert("OnSetPos"), p.Insert(float(spawnas_x) * 32, float(spawnas_y) * 32), p.CreatePacket(peer); if (not pInfo(peer)->invis) { gamepacket_t p(delay, pInfo(peer)->netID); p.Insert("OnPlayPositioned"), p.Insert("audio/door_open.wav"), p.CreatePacket(peer); } } p2.Insert("OnZoomCamera"), p2.Insert((float)10000.000000), p2.Insert(1000), p2.CreatePacket(peer); p3.Insert("OnSetFreezeState"), p3.Insert(0), p3.CreatePacket(peer); return; } else if (not pInfo(peer)->world.empty()) exit_(peer, true); pInfo(peer)->lock = 0; pInfo(peer)->world = world_.name; int total = 78 + world_.name.length() + world_.blocks.size() + 24 + ((8 * world_.blocks.size()) + (world_.drop.size() * 16)); int spawn_x = 0, spawn_y = 0; // BYTE* data = (BYTE*)malloc((world_.blocks.size()*2) * sizeof(WorldBlock) + sizeof(World)); BYTE* data = (BYTE*)malloc(world_.blocks.size() * sizeof(WorldBlock) + (sizeof(World) * 2)); memset(data, 0, total); *(__int8*)(data) = 4; *(__int8*)(data + 4) = 4; *(__int8*)(data + 16) = 8; *(__int8*)(data + 66) = world_.name.length(); memcpy(data + 68, world_.name.c_str(), world_.name.length()); *(__int8*)(data + 68 + world_.name.length()) = 100; *(__int8*)(data + 72 + world_.name.length()) = 60; *(__int16*)(data + 76 + world_.name.length()) = world_.blocks.size(); BYTE* blc = data + 80 + world_.name.length(); vector<vector<unsigned int>> world_locks; world_.active_jammers.clear(); vector<string> world_mods; //vector<int> blocks; for (int i_ = 0; i_ < 6000; i_++) { /* if (find(blocks.begin(), blocks.end(), world_.blocks[i_].fg) == blocks.end()) { blocks.push_back(world_.blocks[i_].fg); cout << world_.blocks[i_].fg << endl; }*/ // if (world_.blocks[i_].fg == 6950 || world_.blocks[i_].fg == 6952 || world_.blocks[i_].fg == 6954) world_.blocks[i_].fg = 2; *(__int16*)(blc) = world_.blocks[i_].fg; *(__int16*)(blc + 2) = world_.blocks[i_].bg; *(__int32*)(blc + 4) = world_.blocks[i_].flags; if (world_.blocks.at(i_).flags & 0x00400000 && (world_.blocks.at(i_).fg == 226 || world_.blocks.at(i_).fg == 1276 || world_.blocks.at(i_).fg == 1278 || world_.blocks.at(i_).fg == 4884 || world_.blocks.at(i_).fg == 4992)) world_mods.push_back("`" + a + (world_.blocks.at(i_).fg == 226 ? "4JAMMED" : (world_.blocks.at(i_).fg == 1276 ? "2NOPUNCH" : (world_.blocks.at(i_).fg == 1278 ? "2IMMUNE" : (world_.blocks.at(i_).fg == 4884 ? "2NOWAR" : "2ANTIGRAVITY")))) + "``"), world_.active_jammers.push_back(world_.blocks.at(i_).fg); if (world_.blocks[i_].fg == 5638 || world_.blocks[i_].fg == 6948 || world_.blocks[i_].fg == 6946) { *(__int8*)(blc + 8) = 62; *(__int16*)(blc + 9) = world_.blocks[i_].id; *(__int16*)(blc + 13) = world_.blocks[i_].pr; *(__int8*)(blc + 17) = world_.blocks[i_].enabled; if (world_.blocks[i_].fg == 5638)*(__int16*)(blc + 18) = world_.blocks[i_].magnetron; *(__int16*)(blc + 20) = (world_.blocks[i_].fg == 5638 ? 5000 : 1500); blc += 15; total += 15; } else if (items[world_.blocks[i_].fg].actionType == -115 || world_.blocks[i_].fg == 3760 || world_.blocks[i_].fg == 6950 || world_.blocks[i_].fg == 6952 || world_.blocks[i_].fg == 6954) { *(__int8*)(blc + 8) = 6; blc += 8; total += 8; } /* else if (world_.blocks[i_].fg == 6950 || world_.blocks[i_].fg == 6952 || world_.blocks[i_].fg == 6954) { *(__int8*)(blc + 8) = world_.blocks[i_].fg == 6950 ? 70 : 69; *(__int8*)(blc + 9) = world_.blocks[i_].pr > 0 ? 1 : 0; *(__int16*)(blc + 13) = world_.blocks[i_].pr; *(__int16*)(blc + 17) = world_.blocks[i_].id; *(__int8*)(blc + 21) = world_.blocks[i_].enabled; blc += 13; total += 13; }*/ else if (items[world_.blocks[i_].fg].easel) { *(__int8*)(blc + 8) = 35; *(__int16*)(blc + 9) = world_.blocks[i_].id; *(__int16*)(blc + 13) = world_.blocks[i_].txt.size(); memcpy(blc + 15, world_.blocks[i_].txt.c_str(), world_.blocks[i_].txt.size()); blc += 7 + world_.blocks[i_].txt.size(); total += 7 + world_.blocks[i_].txt.size(); } else if (items[world_.blocks[i_].fg].bunny_egg) { *(__int8*)(blc + 8) = 15; *(__int16*)(blc + 9) = world_.blocks[i_].bunny_egg_progress; blc += 5; total += 5; } else if (items[world_.blocks[i_].fg].dshelf) { *(__int8*)(blc + 8) = 43; *(__int16*)(blc + 9) = world_.blocks[i_].shelf_1; *(__int16*)(blc + 13) = world_.blocks[i_].shelf_2; *(__int16*)(blc + 17) = world_.blocks[i_].shelf_3; *(__int16*)(blc + 21) = world_.blocks[i_].shelf_4; blc += 17; total += 17; } else if (items[world_.blocks[i_].fg].fish_port) { *(__int8*)(blc + 8) = 63; blc += 1 + 4 + 8; total += 1 + 4 + 8; } else if (items[world_.blocks[i_].fg].timer) { *(__int8*)(blc + 8) = 45; blc += 1; total += 1; } else if (items[world_.blocks[i_].fg].heart_monitor) { *(__int8*)(blc + 8) = 11; { bool ijungtas = false; for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue; if (fixchar(pInfo(currentPeer)->tankIDName) == fixchar(world_.blocks[i_].heart_monitor)) { ijungtas = 1; break; } } /* GlobalMonitors new_monitor; new_monitor.active = ijungtas; new_monitor.world_name = world_.name; new_monitor.x = i_ % 100; new_monitor.y = i_ / 100; monitors.push_back(new_monitor);*/ if (ijungtas)*(int*)(blc + 4) = world_.blocks[i_].flags | 0x00400000; *(int*)(blc + 9) = ijungtas; } *(int*)(blc + 13) = world_.blocks[i_].heart_monitor.size(); memcpy(blc + 15, world_.blocks[i_].heart_monitor.c_str(), world_.blocks[i_].heart_monitor.size()); blc += 7 + world_.blocks[i_].heart_monitor.size(); total += 7 + world_.blocks[i_].heart_monitor.size(); } else if (items[world_.blocks[i_].fg].xeno) { *(__int8*)(blc + 8) = 53; blc += 9; total += 9; } else if (items[world_.blocks[i_].fg].trickster) { *(__int8*)(blc + 8) = 52; blc += 1; total += 1; } else if (items[world_.blocks[i_].fg].charger) { *(int*)(blc + 4) = (world_.blocks[i_].id != 0 ? 0x00400000 : world_.blocks[i_].flags); *(__int8*)(blc + 8) = 57; *(__int16*)(blc + 9) = (world_.blocks[i_].planted - time(nullptr) <= 0 ? 3600 : 3600 - (world_.blocks[i_].planted - time(nullptr))); blc += 5; total += 5; } else if (items[world_.blocks[i_].fg].spirit) { *(__int8*)(blc + 8) = 41; *(__int16*)(blc + 9) = world_.blocks[i_].c_; blc += 5; total += 5; } else if (items[world_.blocks[i_].fg].trans) { *(__int8*)(blc + 8) = 19; blc += 19; total += 19; } else if (items[world_.blocks[i_].fg].mannequin) { *(__int8*)(blc + 8) = 14; *(__int16*)(blc + 9) = world_.blocks[i_].txt.size(); memcpy(blc + 11, world_.blocks[i_].txt.c_str(), world_.blocks[i_].txt.size()); *(__int16*)(blc + 16 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_hair; *(__int16*)(blc + 18 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_shirt; *(__int16*)(blc + 20 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_pants; *(__int16*)(blc + 22 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_feet; *(__int16*)(blc + 24 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_head; *(__int16*)(blc + 26 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_hand; *(__int16*)(blc + 28 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_back; *(__int16*)(blc + 30 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_mask; *(__int16*)(blc + 32 + world_.blocks[i_].txt.size()) = world_.blocks[i_].mannequin.c_neck; blc += 26 + world_.blocks[i_].txt.size(); total += 26 + world_.blocks[i_].txt.size(); } else if (items[world_.blocks[i_].fg].vipentrance) { *(__int8*)(blc + 8) = 44; vector<int> vip_members; if (world_.blocks[i_].limit_admins or find(world_.blocks[i_].admins.begin(), world_.blocks[i_].admins.end(), pInfo(peer)->tankIDName) != world_.blocks[i_].admins.end() or pInfo(peer)->tankIDName == world_.owner_name or world_.owner_name.empty()) vip_members.push_back(pInfo(peer)->id); *(__int16*)(blc + 14) = vip_members.size(); for (int i = 0; i < vip_members.size(); i++) *(__int32*)(blc + 18 + (i * 4)) = vip_members[i]; blc += 10 + (vip_members.size() * 4); total += 10 + (vip_members.size() * 4); } else if (items[world_.blocks[i_].fg].infinitymachine) { *(__int8*)(blc + 8) = 19; blc += 19; total += 19; } else if (items[world_.blocks[i_].fg].portrait) { *(__int8*)(blc + 8) = 48; *(__int16*)(blc + 9) = world_.blocks[i_].txt.size(); memcpy(blc + 11, world_.blocks[i_].txt.c_str(), world_.blocks[i_].txt.size()); if (world_.blocks[i_].portrait.c_skin == 0 and world_.blocks[i_].portrait.c_face == 0 and world_.blocks[i_].portrait.c_head == 0 and world_.blocks[i_].portrait.c_hair == 0) { } else { *(int*)(blc + 11 + world_.blocks[i_].txt.size()) = world_.blocks[i_].portrait.c_expression; *(int*)(blc + 19 + world_.blocks[i_].txt.size()) = world_.blocks[i_].portrait.c_hair_colour; *(int*)(blc + 23 + world_.blocks[i_].txt.size()) = world_.blocks[i_].portrait.c_skin; *(int*)(blc + 27 + world_.blocks[i_].txt.size()) = world_.blocks[i_].portrait.c_face; *(int*)(blc + 29 + world_.blocks[i_].txt.size()) = world_.blocks[i_].portrait.c_head; *(int*)(blc + 31 + world_.blocks[i_].txt.size()) = world_.blocks[i_].portrait.c_hair; } blc += 7 + 15 + 3 + world_.blocks[i_].txt.size(); total += 7 + 15 + 3 + world_.blocks[i_].txt.size(); } else if (items[world_.blocks[i_].fg].vall_mount/*|| world_.blocks[i_].fg == 6950 || world_.blocks[i_].fg == 6952 || world_.blocks[i_].fg == 6954*/) { *(__int8*)(blc + 8) = 47; *(__int8*)(blc + 9) = 0; blc += 8; total += 8; } else if (items[world_.blocks[i_].fg].bulletin_board or items[world_.blocks[i_].fg].storage_box or items[world_.blocks[i_].fg].growscan or items[world_.blocks[i_].fg].security_camera or items[world_.blocks[i_].fg].spotlight or world_.blocks[i_].fg == 4722) { *(__int8*)(blc + 8) = 6; blc += 8; total += 8; } else if (world_.blocks[i_].fossil) { *(__int32*)(blc + 4) = world_.blocks[i_].flags; *(__int8*)(blc + 8) = 12; //blc += 0; //total += 0; } else { switch (items[world_.blocks[i_].fg].blockType) { case BlockTypes::WEATHER: { switch (world_.blocks[i_].fg) { case 3694: case 5000: { *(__int8*)(blc + 8) = 40; *(__int32*)(blc + 9) = (world_.blocks[i_].fg == 3694 ? (world_.blocks[i_].b << 24) | (world_.blocks[i_].g << 16) | (world_.blocks[i_].r << 8) : world_.blocks[i_].id != 0 ? world_.blocks[i_].id : 14); blc += 5; total += 5; break; } case 3832: { *(__int8*)(blc + 8) = 49; *(__int16*)(blc + 9) = (world_.blocks[i_].id != 0 ? world_.blocks[i_].id : 2); *(__int16*)(blc + 13) = world_.blocks[i_].gravity; *(__int16*)(blc + 17) = (int)world_.blocks[i_].spin | ((int)world_.blocks[i_].invert << 1); blc += 10; total += 10; break; } default: { if (items[world_.blocks[i_].fg].ext_weather) { *(__int8*)(blc + 8) = 5; blc += 1; total += 1; } break; } } break; } case BlockTypes::CRYSTAL: { *(__int8*)(blc + 8) = 6; blc += 8; total += 8; break; } case BlockTypes::VENDING: { *(int*)(blc + 9) = (world_.blocks[i_].pr < 0 and world_.blocks[i_].id != 0 && world_.blocks[i_].c_ < (world_.blocks[i_].pr * -1) ? 0 : world_.blocks[i_].id); *(__int8*)(blc + 8) = 24; *(int*)(blc + 4) = (world_.blocks[i_].pr < 0 and world_.blocks[i_].id != 0 && world_.blocks[i_].c_ < (world_.blocks[i_].pr * -1) ? world_.blocks[i_].flags | ((world_.blocks[i_].c_ < (world_.blocks[i_].pr * -1)) ? (world_.blocks[i_].wl != 0 ? 0x02410000 : 0x00410000) : (world_.blocks[i_].wl != 0 ? 0x02410000 : 0x00410000)) : world_.blocks[i_].flags | (world_.blocks[i_].id == 0 ? (world_.blocks[i_].wl != 0 ? 0x02000000 : 0x00000000) : (world_.blocks[i_].wl != 0 ? 0x02410000 : 0x00410000))); *(int*)(blc + 13) = (world_.blocks[i_].pr < 0 and world_.blocks[i_].id != 0 && world_.blocks[i_].c_ < (world_.blocks[i_].pr * -1) ? 0 : world_.blocks[i_].pr); blc += 9; total += 9; break; } case BlockTypes::DISPLAY: { *(__int8*)(blc + 8) = 23; *(__int16*)(blc + 9) = world_.blocks[i_].id; blc += 5; total += 5; break; } case BlockTypes::PROVIDER: { *(__int8*)(blc + 8) = 9; *(__int32*)(blc + 9) = (time(nullptr) - world_.blocks[i_].planted <= items[world_.blocks[i_].fg].growTime ? time(nullptr) - world_.blocks[i_].planted : items[world_.blocks[i_].fg].growTime); blc += 5; total += 5; break; } case BlockTypes::RANDOM_BLOCK: { *(__int8*)(blc + 8) = 8; *(__int32*)(blc + 9) = world_.blocks[i_].roll; blc += 2; total += 2; break; } case BlockTypes::LOCK: { if (world_.blocks[i_].fg == 5814) { *(__int8*)(blc + 8) = 6; blc += 8; total += 8; } else { if (world_.blocks[i_].fg == 202 or world_.blocks[i_].fg == 204 or world_.blocks[i_].fg == 206 or world_.blocks[i_].fg == 4994) world_locks.push_back({ i_ % xSize, i_ / xSize }); else pInfo(peer)->lock = world_.blocks[i_].fg; if (world_.blocks[i_].open_to_public) { *(int*)(blc + 4) = 0x00800000; } *(__int8*)(blc + 8) = 3; uint8_t world_settings = world_.disable_music_blocks ? (world_.make_music_blocks_invisible ? 12345 : 1234) : (world_.make_music_blocks_invisible ? 100 : 0); if (world_.rainbows and world_.blocks[i_].fg == 4802) world_settings += 128; *(__int16*)(blc + 9) = world_settings; *(int*)(blc + 10) = (world_.blocks[i_].owner_name == pInfo(peer)->tankIDName || world_.owner_name == pInfo(peer)->tankIDName ? pInfo(peer)->id : -1); *(__int16*)(blc + 18) = world_.music_bpm * -1; bool access = false; uint16_t count_of_admins = 1; { if (world_.blocks[i_].fg == 202 or world_.blocks[i_].fg == 204 or world_.blocks[i_].fg == 206 or world_.blocks[i_].fg == 4994) if (find(world_.blocks[i_].admins.begin(), world_.blocks[i_].admins.end(), pInfo(peer)->tankIDName) != world_.blocks[i_].admins.end())access = true; //if (world_.blocks[i_].fg == 5814) if (guild_access(peer, world_.guild_id))access = true; if (world_.owner_name != "") if (find(world_.admins.begin(), world_.admins.end(), pInfo(peer)->tankIDName) != world_.admins.end()) access = true; if (access) *(int*)(blc + 22) = pInfo(peer)->id, count_of_admins++; } *(__int8*)(blc + 14) = count_of_admins; blc += 10 + (count_of_admins * 4); total += 10 + (count_of_admins * 4); } break; } case BlockTypes::MAIN_DOOR: { spawn_x = (i_ % xSize) * 32, spawn_y = (i_ / xSize) * 32; pInfo(peer)->c_x = spawn_x / 32; pInfo(peer)->c_y = spawn_y / 32; *(__int8*)(blc + 8) = 1; *(__int16*)(blc + 9) = 4; memcpy(blc + 11, "EXIT", 4); blc += 8; total += 8; break; } case BlockTypes::SEED: { *(int*)(blc + 4) = 0 | 0x100000; *(__int8*)(blc + 8) = 4; *(int*)(blc + 9) = (time(nullptr) - world_.blocks[i_].planted <= items.at(world_.blocks[i_].fg).growTime ? time(nullptr) - world_.blocks[i_].planted : items.at(world_.blocks[i_].fg).growTime); *(__int16*)(blc + 13) = world_.blocks[i_].fruit; blc += 6; total += 6; break; } case BlockTypes::DONATION:case BlockTypes::MAILBOX: { *(__int32*)(blc + 4) = world_.blocks[i_].flags; *(__int8*)(blc + 8) = 12; blc += 8; total += 8; break; } case BlockTypes::DOOR: case BlockTypes::PORTAL: { string duru_tekstas = (world_.blocks[i_].txt.empty() ? (world_.blocks[i_].door_destination.empty() ? "" : (world_.blocks[i_].door_destination.find(":") != string::npos ? explode(":", world_.blocks[i_].door_destination)[0] + "..." : world_.blocks[i_].door_destination)) : world_.blocks[i_].txt); *(__int8*)(blc + 8) = 1; *(__int16*)(blc + 9) = duru_tekstas.size(); memcpy(blc + 11, duru_tekstas.c_str(), duru_tekstas.size()); *(__int8*)(blc + 11 + duru_tekstas.size()) = (world_.blocks[i_].open ? 0 : 0x08); blc += 4 + duru_tekstas.size(); total += 4 + duru_tekstas.size(); break; } case BlockTypes::SIGN: { *(__int8*)(blc + 8) = 2; *(int*)(blc + 9) = world_.blocks[i_].txt.size(); memcpy(blc + 11, world_.blocks[i_].txt.c_str(), world_.blocks[i_].txt.size()); *(__int16*)(blc + 11 + world_.blocks[i_].txt.size()) = 0; blc += 7 + world_.blocks[i_].txt.size(); total += 7 + world_.blocks[i_].txt.size(); break; } } } blc += 8; } *(int*)(blc) = world_.drop.size(); *(int*)(blc + 4) = world_.drop.size(); blc += 8; for (int i_ = 0; i_ < world_.drop.size(); i_++) { *(__int16*)(blc) = world_.drop[i_].id; *(float*)(blc + 2) = world_.drop[i_].x; *(float*)(blc + 6) = world_.drop[i_].y; *(__int8*)(blc + 10) = world_.drop[i_].count; *(int*)(blc + 12) = world_.drop[i_].uid; blc += 16; } enet_peer_send(peer, 0, enet_packet_create(data, total, ENET_PACKET_FLAG_RELIABLE)); delete[] data; if (world_locks.size() > 0) { vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name_](const World& a) { return a.name == name_; }); if (p != worlds.end()) { World* world_pointer_ = &worlds[p - worlds.begin()]; vector<WorldBlock> shadow_copy_2 = world_.blocks; for (vector<unsigned int> sk_ : world_locks) { int l_x = sk_[0]; int l_y = sk_[1]; WorldBlock block_ = world_.blocks[l_x + (l_y * 100)]; block_.owner_named = block_.owner_name; world_pointer_->blocks[l_x + (l_y * 100)].owner_named = block_.owner_named; world_.blocks[l_x + (l_y * 100)].owner_named = block_.owner_name; vector<vector<int>> locked_tiles_around_lock{}; vector<int> new_tiles{}; new_tiles.push_back(l_x + (l_y * 100)); for (int i2 = 0; i2 < new_tiles.size(); i2++) { int s_x_ = new_tiles[i2] % 100, s_y_ = new_tiles[i2] / 100; if (s_x_ < 99 and shadow_copy_2[s_x_ + 1 + (s_y_ * 100)].locked and shadow_copy_2[s_x_ + 1 + (s_y_ * 100)].lock_origin == (l_x + (l_y * 100))) { if (not shadow_copy_2[s_x_ + 1 + (s_y_ * 100)].scanned) { shadow_copy_2[s_x_ + 1 + (s_y_ * 100)].scanned = true; new_tiles.push_back(s_x_ + 1 + (s_y_ * 100)); locked_tiles_around_lock.push_back({ s_x_ + 1, s_y_ }); } } if (s_x_ > 0 and shadow_copy_2[s_x_ - 1 + (s_y_ * 100)].locked and shadow_copy_2[s_x_ - 1 + (s_y_ * 100)].lock_origin == (l_x + (l_y * 100))) { if (not shadow_copy_2[s_x_ - 1 + (s_y_ * 100)].scanned) { shadow_copy_2[s_x_ - 1 + (s_y_ * 100)].scanned = true; new_tiles.push_back(s_x_ - 1 + (s_y_ * 100)); locked_tiles_around_lock.push_back({ s_x_ - 1, s_y_ }); } } if (s_y_ < 59 and shadow_copy_2[s_x_ + ((s_y_ + 1) * 100)].locked and shadow_copy_2[s_x_ + ((s_y_ + 1) * 100)].lock_origin == (l_x + (l_y * 100))) { if (not shadow_copy_2[s_x_ + ((s_y_ + 1) * 100)].scanned) { shadow_copy_2[s_x_ + ((s_y_ + 1) * 100)].scanned = true; new_tiles.push_back(s_x_ + ((s_y_ + 1) * 100)); locked_tiles_around_lock.push_back({ s_x_, s_y_ + 1 }); } } if (s_y_ > 0 and shadow_copy_2[s_x_ + ((s_y_ - 1) * 100)].locked and shadow_copy_2[s_x_ + ((s_y_ - 1) * 100)].lock_origin == (l_x + (l_y * 100))) { if (not shadow_copy_2[s_x_ + ((s_y_ - 1) * 100)].scanned) { shadow_copy_2[s_x_ + ((s_y_ - 1) * 100)].scanned = true; new_tiles.push_back(s_x_ + ((s_y_ - 1) * 100)); locked_tiles_around_lock.push_back({ s_x_, s_y_ - 1 }); } } } if (locked_tiles_around_lock.size() != 0) { PlayerMoving data_{}; data_.packetType = 15, data_.punchX = l_x, data_.punchY = l_y, data_.characterState = 0x8; data_.netID = block_.owner_name == (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->tankIDName) ? pInfo(peer)->id : -1; data_.plantingTree = block_.fg; BYTE* raw; int alloc = alloc_(&world_, &block_); raw = packPlayerMoving(&data_, 112 + (locked_tiles_around_lock.size() * 2) + alloc); *(int*)(raw + 8) = locked_tiles_around_lock.size(); *(__int8*)(raw + 12) = 8; BYTE* blc = raw + 56; for (int i_ = 0; i_ < locked_tiles_around_lock.size(); i_++) { vector<int> update_tiles = locked_tiles_around_lock[i_]; int x = update_tiles[0]; int y = update_tiles[1]; int sq_ = x + (y * 100); *(int*)(blc + (i_ * 2)) = sq_; shadow_copy_2[x + (y * 100)].scanned = false; } send_raw(peer, 4, raw, 112 + (locked_tiles_around_lock.size() * 2) + alloc, ENET_PACKET_FLAG_RELIABLE); PlayerMoving data_2{}; data_2.packetType = 5, data_2.punchX = l_x, data_2.punchY = l_y, data_2.characterState = 0x8; BYTE* raw2 = packPlayerMoving(&data_2, 112 + alloc); BYTE* blc2 = raw2 + 56; form_visual(blc2, block_, world_, peer, false); send_raw(peer, 4, raw2, 112 + alloc, ENET_PACKET_FLAG_RELIABLE); delete[] raw, blc, raw2, blc2; } } } } bool wipe = false; for (int i_ = 0; i_ < pInfo(peer)->inv.size(); i_++) { if (pInfo(peer)->inv[i_].id == 1424 || pInfo(peer)->inv[i_].id == 5816 || pInfo(peer)->inv[i_].id == 5640) { wipe = true; pInfo(peer)->inv[i_].id = 0; pInfo(peer)->inv[i_].count = 0; if (pInfo(peer)->inv[i_].id == 5640) pInfo(peer)->magnetron_id = 0, pInfo(peer)->magnetron_x = 0, pInfo(peer)->magnetron_y = 0; } } if (wipe) send_inventory(peer); pInfo(peer)->netID = net_; if (spawnas_x != 0 or spawnas_y != 0) spawn_x = spawnas_x * 32, spawn_y = spawnas_y * 32; pInfo(peer)->name_color = boosterTag(peer) + (((pInfo(peer)->adminLevel != 0) ? adminTag(pInfo(peer)->adminLevel) : (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->tankIDName) == world_.owner_name ? "`2" : (/*guild_access(peer, world_.guild_id) or */ find(world_.admins.begin(), world_.admins.end(), (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->tankIDName)) != world_.admins.end()) ? "`^" : "`0")); gamepacket_t /*p,*/ p2, p3; /* p.Insert("OnSetBux"), p.Insert(pInfo(peer)->gems), p.Insert(1), p.Insert((pInfo(peer)->supp >= 1) ? 1 : 0); if (pInfo(peer)->supp >= 2) p.Insert((float)33796, (float)1, (float)0); p.CreatePacket(peer);*/ { /* gamepacket_t pb; pb.Insert((world_.name == "BEACHPARTYGAME" ? "ShowPearlCurrency" : "HidePearlCurrency")); pb.CreatePacket(peer); add_pearl(peer);*/ } p2.Insert("OnConsoleMessage"), p2.Insert("" + (pInfo(peer)->mod + pInfo(peer)->dev > 0 ? (world_.nuked ? "`0[NUKED: " + world_.n_b + "," + world_.n_t + "]`` " : "") : "") + "World `w" + world_.name + "`` " + (world_mods.size() != 0 ? "`0[``" + join(world_mods, ", ") + "`0]`` " : "") + "" + "entered. There are `w" + to_string(w_c) + "`` other people here, `w" + setGems(s_c * 6 + 1) + "`` online."), p2.CreatePacket(peer); p3.Insert("OnSetCurrentWeather"); p3.Insert((world_.weather == 0 || world_.weather == 80 && world_.d_weather != 0 ? world_.d_weather : (world_.weather == 0 ? 80 : world_.weather))); p3.CreatePacket(peer); { string s_ = "spawn|avatar\nnetID|" + to_string(net_) + "\nuserID|" + to_string(pInfo(peer)->id) + "\ncolrect|0|0|20|30\nposXY|" + to_string(spawn_x) + "|" + to_string(spawn_y) + "\nname|" + (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->name_color + (pInfo(peer)->tankIDName.empty() ? pInfo(peer)->requestedName : pInfo(peer)->tankIDName)) + (pInfo(peer)->is_legend ? " of Legend" : "") + "``\ncountry|" + pInfo(peer)->country + "\ninvis|" + (pInfo(peer)->invis ? "1" : "0") + "\nmstate|" + (pInfo(peer)->mod or pInfo(peer)->dev ? "1" : "0") + "\nsmstate|" + (pInfo(peer)->dev ? "1" : "0") + "\nonlineID|"; gamepacket_t p; p.Insert("OnSpawn"), p.Insert(s_); { gamepacket_t p; p.Insert("OnSpawn"), p.Insert(s_ + "\ntype|local"), p.CreatePacket(peer); } gamepacket_t p57, p58; p57.Insert("OnTalkBubble"), p57.Insert(pInfo(peer)->netID), p57.Insert("`5<" + (not pInfo(peer)->d_name.empty() ? (pInfo(peer)->d_name.substr(0, 1) == "`" ? "" : "`w") + pInfo(peer)->d_name + "``" : pInfo(peer)->name_color + pInfo(peer)->tankIDName + "``") + " entered, `w" + to_string(w_c) + "`` others here>``"), p57.Insert(1); p58.Insert("OnConsoleMessage"), p58.Insert("`5<" + (not pInfo(peer)->d_name.empty() ? (pInfo(peer)->d_name.substr(0, 1) == "`" ? "" : "`w") + pInfo(peer)->d_name + "``" : pInfo(peer)->name_color + pInfo(peer)->tankIDName + "``") + " entered, `w" + to_string(w_c) + "`` others here>``"); for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world != name_ or pInfo(peer)->tankIDName == pInfo(currentPeer)->tankIDName) continue; p.CreatePacket(currentPeer); gamepacket_t p; p.Insert("OnSpawn"), p.Insert("spawn|avatar\nnetID|" + to_string(pInfo(currentPeer)->netID) + "\nuserID|" + to_string(pInfo(currentPeer)->id) + "\ncolrect|0|0|20|30\nposXY|" + to_string(pInfo(currentPeer)->x) + "|" + to_string(pInfo(currentPeer)->y) + "\nname|" + (not pInfo(currentPeer)->d_name.empty() ? pInfo(currentPeer)->d_name : pInfo(currentPeer)->name_color + (pInfo(currentPeer)->tankIDName.empty() ? pInfo(currentPeer)->requestedName : pInfo(currentPeer)->tankIDName)) + (pInfo(currentPeer)->is_legend ? " of Legend" : "") + "``\ncountry|" + pInfo(currentPeer)->country + "\ninvis|" + (pInfo(currentPeer)->invis ? "1" : "0") + "\nmstate|" + (pInfo(currentPeer)->mod or pInfo(currentPeer)->dev ? "1" : "0") + "\nsmstate|" + (pInfo(currentPeer)->dev ? "1" : "0") + "\nonlineID|"), p.CreatePacket(peer); if (w_c <= 14 && w_c >= 1 && pInfo(peer)->invis == false) p57.CreatePacket(currentPeer), p58.CreatePacket(currentPeer); } } if (not world_.owner_name.empty()) { if (world_.owner_named.substr(0, 2) == "`2") world_.owner_named = "`o" + world_.owner_name; if (world_.owner_named == "" && (pInfo(peer)->tankIDName == world_.owner_name && world_.owner_named != pInfo(peer)->tankIDName)) { world_.owner_named = "`o" + pInfo(peer)->tankIDName; if (pInfo(peer)->adminLevel >= 1) world_.owner_named = adminTag(pInfo(peer)->adminLevel) + pInfo(peer)->tankIDName; } gamepacket_t p; p.Insert("OnConsoleMessage"); p.Insert("`5[```w" + world_.name + "`` `$World Locked`` by " + (world_.owner_named == "" ? world_.owner_name : world_.owner_named) + "``" + (world_.owner_name == (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->tankIDName) or (/*guild_access(peer, world_.guild_id) or */ find(world_.admins.begin(), world_.admins.end(), (not pInfo(peer)->d_name.empty() ? pInfo(peer)->d_name : pInfo(peer)->tankIDName)) != world_.admins.end()) ? " (`2ACCESS GRANTED``)" : (world_.open_to_public ? " (`$PUBLIC``)" : "")) + "`5]``"); p.CreatePacket(peer); } if (world_.special_event) { gamepacket_t p2; p2.Insert("OnConsoleMessage"), p2.Insert("`2" + items[world_.special_event_item].event_name + ":`` " + (items[world_.special_event_item].event_total == 1 ? "`oYou have`` `030`` `oseconds to find and grab the`` `#" + items[world_.special_event_item].name + "```o.``" : "`#" + to_string(items[world_.special_event_item].event_total) + " " + items[world_.special_event_item].name + "`` `ospawn in your world, you have`` `030`` `oseconds to collect them.``") + ""), p2.CreatePacket(peer); } { gamepacket_t p; p.Insert("OnSpawn"), p.Insert("spawn|avatar\nnetID|" + to_string(rand() % 30 + 450) + "\nuserID|288286691\ncolrect|0|0|20|30\nposXY|-32|-32\nname|`6@chris``\ncountry|us\ninvis|1\nmstate|1\nsmstate|1\nonlineID|"), p.CreatePacket(peer); } for (int i_ = 0; i_ < pInfo(peer)->last_visited_worlds.size(); i_++) { if (pInfo(peer)->last_visited_worlds[i_] == world_.name) { pInfo(peer)->last_visited_worlds.erase(pInfo(peer)->last_visited_worlds.begin() + i_); pInfo(peer)->last_visited_worlds.push_back(world_.name); } else if (i_ + 1 == pInfo(peer)->last_visited_worlds.size()) { if (pInfo(peer)->last_visited_worlds.size() + 1 > 11) { pInfo(peer)->last_visited_worlds.erase(pInfo(peer)->last_visited_worlds.begin()); } pInfo(peer)->last_visited_worlds.push_back(world_.name); } } if (pInfo(peer)->last_visited_worlds.size() == 0) pInfo(peer)->last_visited_worlds.push_back(world_.name); if (not pInfo(peer)->invis) packet_(peer, "action|play_sfx\nfile|audio/door_open.wav\ndelayMS|0"); for (int i_ = 0; i_ < world_.machines.size(); i_++) { WorldMachines machine_ = world_.machines[i_]; WorldBlock block_ = world_.blocks[machine_.x + (machine_.y * 100)]; int alloc = alloc_(&world_, &block_); PlayerMoving data_{}; data_.packetType = 5, data_.punchX = machine_.x, data_.punchY = machine_.y, data_.characterState = 0x8; BYTE* raw = packPlayerMoving(&data_, 112 + alloc); BYTE* blc = raw + 56; form_visual(blc, block_, world_, peer, false); send_raw(peer, 4, raw, 112 + alloc, ENET_PACKET_FLAG_RELIABLE); delete[] raw, blc; } add_cctv(peer, "entered", ""); if (pInfo(peer)->hair == 7102 && door == false) { gamepacket_t p(0, pInfo(peer)->netID); p.Insert("OnAction"), p.Insert("/omg"), p.CreatePacket(peer); } }
Editor is loading...