P_ITEM cTrade::tradestart(UOXSOCKET s, P_CHAR pc_i) { P_CHAR pc_currchar = currchar[s]; unsigned char msg[90]; P_ITEM pi_bps = Packitem(pc_currchar); P_ITEM pi_bpi = Packitem(pc_i); UOXSOCKET s2 = calcSocketFromChar(pc_i); if (pi_bps == NULL) //LB { sysmessage(s, "Time to buy a backpack!"); sysmessage(s2, "%s doesnt have a backpack!", pc_currchar->name.c_str()); return 0; } if (pi_bpi == NULL) { sysmessage(s2, "Time to buy a backpack!"); sysmessage(s, "%s doesnt have a backpack!", pc_i->name.c_str()); return 0; } P_ITEM pi_ps = Items->SpawnItem(s2, pc_currchar, 1, "#", 0, 0x1E, 0x5E, 0, 0, 0); if(pi_ps == NULL) return 0; pi_ps->pos = Coord_cl(26, 0, 0); pi_ps->SetContSerial(pc_currchar->serial); pi_ps->layer=0; pi_ps->type=1; pi_ps->dye=0; sendbpitem(s, pi_ps); if (s2 != INVALID_UOXSOCKET) sendbpitem(s2, pi_ps); P_ITEM pi_pi = Items->SpawnItem(s2,pc_i,1,"#",0,0x1E,0x5E,0,0,0); if (pi_pi == NULL) return 0; pi_pi->pos = Coord_cl(26, 0, 0); pi_pi->SetContSerial(pc_i->serial); pi_pi->layer=0; pi_pi->type=1; pi_pi->dye=0; sendbpitem(s, pi_pi); if (s2 != INVALID_UOXSOCKET) sendbpitem(s2, pi_pi); pi_pi->moreb1 = static_cast<unsigned char>((pi_ps->serial&0xFF000000)>>24); pi_pi->moreb2 = static_cast<unsigned char>((pi_ps->serial&0x00FF0000)>>16); pi_pi->moreb3 = static_cast<unsigned char>((pi_ps->serial&0x0000FF00)>>8); pi_pi->moreb4 = static_cast<unsigned char>((pi_ps->serial&0x000000FF)); pi_ps->more1 = static_cast<unsigned char>((pi_pi->serial&0xFF000000)>>24); pi_ps->more2 = static_cast<unsigned char>((pi_pi->serial&0x00FF0000)>>16); pi_ps->more3 = static_cast<unsigned char>((pi_pi->serial&0x0000FF00)>>8); pi_ps->more4 = static_cast<unsigned char>((pi_pi->serial&0x000000FF)); pi_ps->morez = 0; pi_pi->morez = 0; msg[0] = 0x6F; // Header Byte msg[1] = 0; // Size msg[2] = 47; // Size msg[3] = 0; // Initiate LongToCharPtr(pc_i->serial,msg+4); LongToCharPtr(pi_ps->serial,msg+8); LongToCharPtr(pi_pi->serial,msg+12); msg[16]=1; strcpy((char*)&(msg[17]), pc_i->name.c_str()); Xsend(s, msg, 47); if (s2 != INVALID_UOXSOCKET) { msg[0]=0x6F; // Header Byte msg[1]=0; // Size msg[2]=47; // Size msg[3]=0; // Initiate LongToCharPtr(pc_currchar->serial,msg+4); LongToCharPtr(pi_pi->serial,msg+8); LongToCharPtr(pi_ps->serial,msg+12); msg[16]=1; strcpy((char*)&(msg[17]), pc_currchar->name.c_str()); Xsend(s2, msg, 47); } return pi_ps; }
void cTrade::dotrade(P_ITEM cont1, P_ITEM cont2) { int serial; P_CHAR p1 = FindCharBySerial(cont1->contserial); if(p1 == NULL) return; P_CHAR p2 = FindCharBySerial(cont2->contserial); if(p2 == NULL) return; if(cont1->morez==0 || cont2->morez==0) {//not checked - give items to previous owners - AntiChrist P_CHAR t; t = p1; p1 = p2; p2 = t; } P_ITEM bp1 = Packitem(p1); if(bp1 == NULL) return; P_ITEM bp2 = Packitem(p2); if(bp2 == NULL) return; UOXSOCKET s1 = calcSocketFromChar(p1); if (s1 ==-1) cout << "Error getting socket in trade, calcSocketFromChar for s1" << endl; UOXSOCKET s2 = calcSocketFromChar(p2); if (s2 ==-1) cout << "Error getting socket in trade, calcSocketFromChar for si" << endl; serial = cont1->serial; unsigned int ci; vector<SERIAL> vecContainer = contsp.getData(serial); for (ci = 0; ci < vecContainer.size(); ++ci) { P_ITEM pi = FindItemBySerial(vecContainer[ci]); if (pi != NULL) if ((pi->contserial==serial)) { if (pi->glow != INVALID_SERIAL) glowsp.remove(p2->serial, pi->serial); // lb, glowing stuff bp2->AddItem(pi); if (pi->glow != INVALID_SERIAL) glowsp.insert(p1->serial, pi->serial); if (s1!=-1) RefreshItem(pi);//AntiChrist if (s2!=-1) sendbpitem(s2, pi); RefreshItem(pi);//AntiChrist } } serial = cont2->serial; vecContainer.clear(); vecContainer = contsp.getData(serial); for (ci = 0; ci < vecContainer.size(); ++ci) { P_ITEM pi = FindItemBySerial(vecContainer[ci]); if (pi != NULL) if ((pi->contserial==serial)) { if (pi->glow != INVALID_SERIAL) glowsp.remove(p2->serial, pi->serial); // lb, glowing stuff bp1->AddItem(pi); if (pi->glow != INVALID_SERIAL) glowsp.insert(currchar[s1]->serial, pi->serial); if (s2 != INVALID_UOXSOCKET) RefreshItem(pi);//AntiChrist if (s1 != INVALID_UOXSOCKET) sendbpitem(s1, pi); RefreshItem(pi);//AntiChrist } } }
void wear_item(NXWCLIENT ps) // Item is dropped on paperdoll { if ( ps == NULL ) return; NXWSOCKET s = ps->toInt(); if (s < 0) return; P_CHAR pc=ps->currChar(); VALIDATEPC( pc ); P_CHAR pck = pointers::findCharBySerPtr(buffer[s]+6); VALIDATEPC( pck ); if( pck->dead ) //Exploit fix: Dead ppl can't equip anything. return; P_ITEM pi=pointers::findItemBySerPtr(buffer[s]+1); VALIDATEPI(pi); bool resetDragging = false; if( (pi->getId()>>8) >= 0x40) // LB, client crashfix if multi-objects are moved to PD resetDragging = true; tile_st tile; int serial/*, letsbounce=0*/; // AntiChrist (5) - new ITEMHAND system data::seekTile(pi->getId(), tile); if( ( clientDimension[s]==3 ) && (tile.quality==0) ) { ps->sysmsg(TRANSLATE("You can't wear that")); resetDragging = true; } else { P_ITEM outmost = pi->getOutMostCont(); P_CHAR vendor = pointers::findCharBySerial( outmost->getContSerial() ); if( ISVALIDPC( vendor ) && ( vendor->getOwnerSerial32() != pc->getSerial32() ) ) { resetDragging = true; } } if( resetDragging ) { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } if ( pck->getSerial32() == pc->getSerial32() || pc->IsGM() ) { if ( !pc->IsGM() && pi->st > pck->getStrength() && !pi->isNewbie() ) // now you can equip anything if it's newbie { ps->sysmsg(TRANSLATE("You are not strong enough to use that.")); resetDragging = true; } else if ( !pc->IsGM() && !checkItemUsability(pc, pi, ITEM_USE_WEAR) ) { resetDragging = true; } else if ( (pc->getId() == BODY_MALE) && ( pi->getId()==0x1c00 || pi->getId()==0x1c02 || pi->getId()==0x1c04 || pi->getId()==0x1c06 || pi->getId()==0x1c08 || pi->getId()==0x1c0a || pi->getId()==0x1c0c ) ) // Ripper...so males cant wear female armor { ps->sysmsg(TRANSLATE("You cant wear female armor!")); resetDragging = true; } else if ((((pi->magic==2)||((tile.weight==255)&&(pi->magic!=1))) && !pc->canAllMove()) || ( (pi->magic==3|| pi->magic==4) && !(pi->getOwnerSerial32()==pc->getSerial32()))) { resetDragging = true; } if( resetDragging ) { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } // - AntiChrist (4) - checks for new ITEMHAND system // - now you can't equip 2 hnd weapons with 1hnd weapons nor shields!! serial= pck->getSerial32(); //xan -> k not cc :) P_ITEM pj = NULL; P_CHAR pc_currchar= pck; // P_ITEM pack= pc_currchar->getBackpack(); //<Luxor> P_ITEM pW = pc_currchar->getWeapon(); if (tile.quality == 1 || tile.quality == 2) { //weapons layers if ( (pi->layer == LAYER_2HANDWEAPON && ISVALIDPI(pc_currchar->getShield())) ) { ps->sysmsg(TRANSLATE("You cannot wear two weapons.")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } if (ISVALIDPI(pW)) { if (pi->itmhand != 3 && pi->lodamage != 0 && pi->itmhand == pW->itmhand) { ps->sysmsg(TRANSLATE("You cannot wear two weapons.")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } } } //</Luxor> int drop[2]= {-1, -1}; // list of items to drop // there no reason for it to be larger int curindex= 0; NxwItemWrapper si; si.fillItemWeared( pc_currchar, false, true, true ); for( si.rewind(); !si.isEmpty(); si++ ) { // we CANNOT directly bounce the item, or the containersearch() function will not work // so we store the item ID in letsbounce, and at the end we bounce the item pj=si.getItem(); if(!ISVALIDPI(pj)) continue; if ((tile.quality == 1) || (tile.quality == 2))// weapons { if (pi->itmhand == 2) // two handed weapons or shield { if (pj->itmhand == 2) drop[curindex++]= DEREF_P_ITEM(pj); if ( (pj->itmhand == 1) || (pj->itmhand == 3) ) drop[curindex++]= DEREF_P_ITEM(pj); } if (pi->itmhand == 3) { if ((pj->itmhand == 2) || pj->itmhand == 3) drop[curindex++]= DEREF_P_ITEM(pj); } if ((pi->itmhand == 1) && ((pj->itmhand == 2) || (pj->itmhand == 1))) drop[curindex++]= DEREF_P_ITEM(pj); } else // not a weapon { if (pj->layer == tile.quality) drop[curindex++]= DEREF_P_ITEM(pj); } } if (ServerScp::g_nUnequipOnReequip) { if (drop[0] > -1) // there is at least one item to drop { for (int i= 0; i< 2; i++) { if (drop[i] > -1) { P_ITEM p_drop=MAKE_ITEM_REF(drop[i]); if(ISVALIDPI(p_drop)) pc_currchar->UnEquip( p_drop, 0); } } } pc->playSFX( itemsfx(pi->getId()) ); // pc_currchar->Equip(pi, 1); // Item is equipped twice ???? } else { if (drop[0] == -1) { pc->playSFX( itemsfx(pi->getId()) ); // pc_currchar->Equip(pi, 1);// Item is equipped twice ???? } else { ps->sysmsg("You cannot wear two weapons."); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } } if (!(pc->IsGM())) //Ripper..players cant equip items on other players or npc`s paperdolls. { if ((pck->getSerial32() != pc->getSerial32())/*&&(chars[s].npc!=k)*/) //-> really don't understand this! :|, xan { ps->sysmsg(TRANSLATE("You can't put items on other people!")); item_bounce6(ps,pi); return; } } NxwSocketWrapper sws; sws.fillOnline( pi ); for( sws.rewind(); !sws.isEmpty(); sws++ ) SendDeleteObjectPkt( sws.getSocket(), pi->getSerial32() ); pi->layer=buffer[s][5]; pi->setContSerial(LongFromCharPtr(buffer[s] +6)); if (g_nShowLayers) InfoOut("Item equipped on layer %i.\n",pi->layer); wearIt(s,pi); NxwSocketWrapper sw; sw.fillOnline( pck, false ); for( sw.rewind(); !sw.isEmpty(); sw++ ) { NXWSOCKET j=sw.getSocket(); if( j!=INVALID ) wornitems(j, pck ); } pc->playSFX( itemsfx(pi->getId()) ); weights::NewCalc(pc); // Ison 2-20-99 statwindow(pc_currchar,pc_currchar); // if (pi->glow>0) // { // pc->removeHalo(pi); // if gm equips on differnt player it needs to be deleted out of the hashteble // pck->addHalo(pi); // pck->glowHalo(pi); // } if ( pck->Equip(pi, 1) == 2) // bypass called { P_ITEM pack = pck->getBackpack(); pc->playSFX( itemsfx(pi->getId()) ); pi->layer= 0; pi->setContSerial( pack->getSerial32() ); sendbpitem(s, pi); return; } } }