void MakeStackIcon::setEnable(bool e) { vector<BumpObject *> objectList; float avgX = 0.0f, avgZ = 0.0f; if (e) { objectList = sel->getBumpObjects(); // Get the center of the selection for (uint i = 0; i < objectList.size(); i++) { avgX += objectList[i]->getActor()->getGlobalPosition().x; avgZ += objectList[i]->getActor()->getGlobalPosition().z; } // account for the lasso centroid (we can pull towards the centroid by setting the weight) int lassoWeight = 1; if (lassoWeight > 0) { Vec3 lassoCentroid = lassoMenu->getCentroid(); Vec3 worldLassoCentroid = ClientToWorld((int)lassoCentroid.x, (int)lassoCentroid.y, 0); for (int i = 0; i < lassoWeight; ++i) { avgX += worldLassoCentroid.x; avgZ += worldLassoCentroid.z; } } // Set the position of the stack Icon setPosition(Vec3(avgX / (objectList.size() + lassoWeight), 0.0f, avgZ / (objectList.size() + lassoWeight))); // Fade In alphaInc = 0.05f; }else{ // Fade Out alphaInc = -0.05f; reset(); } enabled = e; }
void LocalSocket::OnRawData(const char *p,size_t l,struct sockaddr *sa_from,socklen_t sa_len) { if (sa_from != NULL && sa_len != 97) { struct sockaddr_in sa; memcpy(&sa,sa_from,sa_len); ipaddr_t a; memcpy(&a,&sa.sin_addr,4); Utility::l2ip(a,GlobalIP); GlobalPort = htons(sa.sin_port); } if (TFDecryptCTW!=NULL && p[0]==0x01) { globalLocalSocket = this; } EnterCriticalSection(&CriticalSection); string outputMe = ClientToWorld(p,l); worldRemote->SendBuf(outputMe.data(),outputMe.size()); LeaveCriticalSection(&CriticalSection); }