Beam *BeamFactory::createLocal(Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::String fname, collision_box_t *spawnbox, bool ismachine, int flareMode, std::vector<Ogre::String> *truckconfig, Skin *skin, bool freePosition) { bool networked=false, networking=false; if (net) networking = true; int truck_num = getFreeTruckSlot(); if (truck_num == -1) { LOG("ERROR: could not add beam to main list"); return 0; } Beam *b = new Beam(truck_num, manager, manager->getRootSceneNode()->createChildSceneNode(), win, net, mapsizex, mapsizez, pos.x, pos.y, pos.z, rot, fname.c_str(), icollisions, mfinder, w, pcam, networked, networking, spawnbox, ismachine, flareMode, truckconfig, skin, freePosition); trucks[truck_num] = b; // lock slidenodes after spawning the truck? if (b->getSlideNodesLockInstant()) b->toggleSlideNodeLock(); lockStreams(); std::map < int, std::map < unsigned int, Beam *> > &streamables = getStreams(); streamables[-1][10 + truck_num] = b; // 10 streams offset for beam constructions unlockStreams(); #ifdef USE_MYGUI GUI_MainMenu::getSingleton().triggerUpdateVehicleList(); #endif // USE_MYGUI // add own username to truck if (net) b->updateNetworkInfo(); return b; }
Beam *BeamFactory::createRemoteInstance(stream_reg_t *reg) { // NO LOCKS IN HERE, already locked stream_register_trucks_t *treg = (stream_register_trucks_t *)®->reg; LOG(" new beam truck for " + TOSTRING(reg->sourceid) + ":" + TOSTRING(reg->streamid)); #ifdef USE_SOCKTEW // log a message about this if (net) { client_t *c = net->getClientInfo(reg->sourceid); if (c) { Ogre::UTFString username = ChatSystem::getColouredName(*c); Ogre::UTFString message = username + ChatSystem::commandColour + _L(" spawned a new vehicle: ") + ChatSystem::normalColour + treg->name; #ifdef USE_MYGUI Console *console = Console::getInstancePtrNoCreation(); if (console) console->putMessage(Console::CONSOLE_MSGTYPE_NETWORK, Console::CONSOLE_VEHILCE_ADD, message, "car_add.png"); #endif // USE_MYGUI } } #endif // USE_SOCKETW bool networked=true, networking=false; if (net) networking = true; // check if we got this truck installed String filename = String(treg->name); String group = ""; if (!CACHE.checkResourceLoaded(filename, group)) { LOG("wont add remote stream (truck not existing): '"+filename+"'"); // add 0 to the map so we know its stream is existing but not usable for us // already locked //lockStreams(); std::map < int, std::map < unsigned int, Beam *> > &streamables = getStreams(); streamables[reg->sourceid][reg->streamid] = 0; //unlockStreams(); return 0; } // fill truckconfig std::vector<Ogre::String> truckconfig; for(int t=0; t<10; t++) { if (!strnlen(treg->truckconfig[t], 60)) break; truckconfig.push_back(String(treg->truckconfig[t])); } // DO NOT spawn the truck far off anywhere // the truck parsing will break flexbodies initialization when using huge numbers here Vector3 pos = Vector3::ZERO; int truck_num = getFreeTruckSlot(); if (truck_num == -1) { LOG("ERROR: could not add beam to main list"); return 0; } Beam *b = new Beam(truck_num, manager, manager->getRootSceneNode(), win, net, mapsizex, mapsizez, pos.x, pos.y, pos.z, Quaternion::ZERO, reg->reg.name, icollisions, mfinder, w, pcam, networked, networking, 0, false, 3, &truckconfig, 0); trucks[truck_num] = b; b->setSourceID(reg->sourceid); b->setStreamID(reg->streamid); // already locked //lockStreams(); std::map < int, std::map < unsigned int, Beam *> > &streamables = getStreams(); streamables[reg->sourceid][reg->streamid] = b; //unlockStreams(); b->updateNetworkInfo(); #ifdef USE_MYGUI GUI_MainMenu::getSingleton().triggerUpdateVehicleList(); #endif // USE_MYGUI return b; }