/* * SetCurrentLine - reset current line after changes in current file structure */ vi_rc SetCurrentLine( linenum lineno ) { int text_lines; fcb *cfcb; line *cline; vi_rc rc; if( lineno <= 0 ) { lineno = 1; } rc = CGimmeLinePtr( lineno, &cfcb, &cline ); if( rc != ERR_NO_ERR ) { return( rc ); } CurrentLine = cline; CurrentFcb = cfcb; text_lines = WindowAuxInfo( current_window_id, WIND_INFO_TEXT_LINES ); if( lineno < LeftTopPos.line || lineno > (LeftTopPos.line + text_lines - 1) ) { LeftTopPos.line = lineno - text_lines / 2; } if( LeftTopPos.line < 1 ) { LeftTopPos.line = 1; } CheckCurrentColumn(); SetCurrentLineNumber( lineno ); UpdateStatusWindow(); SetWindowCursor(); DCDisplayAllLines(); return( ERR_NO_ERR ); } /* SetCurrentLine */
static void totalRedraw( void ) { StatusWndSetSeparatorsWithArray( EditVars.StatusSections, EditVars.NumStatusSections ); UpdateStatusWindow(); InvalidateRect( status_window_id, NULL, TRUE ); UpdateWindow( status_window_id ); }
/* * SetCurrentColumn - set CurrentPos.column, positioning LeftTopPos.column nicely */ vi_rc SetCurrentColumn( int newcol ) { long oldpos; int text_cols; oldpos = CurrentPos.column - LeftTopPos.column; if( newcol <= 0 ) { newcol = 1; } text_cols = WindowAuxInfo( current_window_id, WIND_INFO_TEXT_COLS ); if( oldpos < 0 || oldpos >= text_cols ) { LeftTopPos.column = newcol - SCROLL_HLINE - 1; } else { LeftTopPos.column = newcol - oldpos - 1; } if( LeftTopPos.column < 0 ) { LeftTopPos.column = 0; } CurrentPos.column = newcol; CheckCurrentColumn(); UpdateCursorDrag(); VarAddRandC(); PositionHorizontalScrollThumb( current_window_id, LeftTopPos.column ); UpdateStatusWindow(); SetWindowCursor(); DCDisplayAllLines(); return( ERR_NO_ERR ); } /* SetCurrentColumn */
void Scene_Equip::Update() { help_window->Update(); UpdateEquipWindow(); UpdateStatusWindow(); UpdateItemWindows(); if (equip_window->GetActive()) { UpdateEquipSelection(); } else if (item_window->GetActive()) { UpdateItemSelection(); } }
/* * NewStatusWindow - create a new status window */ vi_rc NewStatusWindow( void ) { vi_rc rc = ERR_NO_ERR; if( !EditFlags.WindowsStarted ) { return( ERR_NO_ERR ); } if( StatusWindow != NO_WINDOW ) { CloseAWindow( StatusWindow ); StatusWindow = NO_WINDOW; } if( EditFlags.StatusInfo ) { rc = NewWindow2( &StatusWindow, &statusw_info ); UpdateStatusWindow(); } return( rc ); } /* NewStatusWindow */
/* * NewStatusWindow - create a new status window */ vi_rc NewStatusWindow( void ) { vi_rc rc = ERR_NO_ERR; if( !EditFlags.WindowsStarted ) { return( ERR_NO_ERR ); } if( !BAD_ID( status_window_id ) ) { CloseAWindow( status_window_id ); status_window_id = NO_WINDOW; } if( EditFlags.StatusInfo ) { rc = NewWindow2( &status_window_id, &statusw_info ); UpdateStatusWindow(); } return( rc ); } /* NewStatusWindow */
/* * toolBarHelp - update tool bar hint text */ static void toolBarHelp( HWND hwnd, ctl_id id, bool isdown ) { ss *p; hwnd = hwnd; SetMenuHelpString( NULL ); if( isdown ) { p = toolBarHead; while( p != NULL ) { tool_item *item = (tool_item *)p; if( item->id == id ) { SetMenuHelpString( item->help ); break; } p = p->next; } } UpdateStatusWindow(); } /* toolBarHelp */
/* * RefreshSSbar - turn status settings bar on/off */ void RefreshSSbar( void ) { static FARPROC proc = NULL; if( EditFlags.SSbar ) { if( !BAD_ID( hSSbar ) ) { return; } proc = MakeDlgProcInstance( SSDlgProc, InstanceHandle ); hSSbar = CreateDialog( InstanceHandle, "SSBAR", root_window_id, (DLGPROC)proc ); } else { if( BAD_ID( hSSbar ) ) { return; } SendMessage( hSSbar, WM_CLOSE, 0, 0L ); FreeProcInstance( proc ); } UpdateStatusWindow(); } /* RefreshSSbar */
/* * RefreshFontbar - turn font bar on/off to reflect current editflag state */ void RefreshFontbar( void ) { static DLGPROC proc; if( EditFlags.Fontbar ) { if( hFontbar != NULL ) { return; } proc = (DLGPROC) MakeProcInstance( (FARPROC) FtDlgProc, InstanceHandle ); hFontbar = CreateDialog( InstanceHandle, "FTBAR", Root, proc ); SetMenuHelpString( "Ctrl affects all syntax elements" ); } else { if( hFontbar == NULL ) { return; } SendMessage( hFontbar, WM_CLOSE, 0, 0L ); FreeProcInstance( (FARPROC) proc ); SetMenuHelpString( "" ); } UpdateStatusWindow(); } /* RefreshFontbar */
/* * GoToColumn - go to a specified column */ vi_rc GoToColumn( int colno, int maxcol ) { int vc; if( CurrentFile == NULL ) { return( ERR_NO_FILE ); } if( maxcol == 0 ) { maxcol = 1; } if( colno == 0 ) { colno = 1; } if( colno < 1 || colno > maxcol ) { return( ERR_NO_SUCH_COLUMN ); } /* * compute new location, and re-display text if needed */ VirtualColumnDesired = VirtualColumnOnCurrentLine( colno ); CurrentPos.column = colno; if( !CheckLeftColumn() ) { DCDisplayAllLines(); PositionHorizontalScrollThumb( current_window_id, LeftTopPos.column ); } SetWindowCursor(); vc = VirtualColumnOnCurrentLine( CurrentPos.column ); UpdateStatusWindow(); VarAddGlobalLong( "C", (long) vc ); UpdateCursorDrag(); return( ERR_NO_ERR ); } /* GoToColumn */
MRESULT EXPENTRY MLECustomProc(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) { SHORT sScrollBarFirst; SHORT sScrollBarLast; static SHORT sScrollBarRange; USHORT idVScroll; USHORT idHScroll; static int iFirstVScroll=0; static int iFirstHScroll=0; static HWND hwndHScroll; static HWND hwndVScroll; MRESULT mres; IPT ipt; //Insertion point IPT iptLineStart; //First insertion point for a line IPT iptTotalLineLength; //Total lenght of a line of text IPT iptCursorToEndLength; //Length from cursor to end of line. static long lCurrentLine; static long lCurrentColumn; int iRes; static BOOL bEnterKeyDown; LONG lColor; switch(msg) { case MLM_SETFONT: FontPalProc(); break; case MLM_SETBACKCOLOR: WinDlgBox(HWND_DESKTOP, hwnd, ColorChgDlgProc, NULLHANDLE, IDD_COLORCHANGE, NULL); //Reshow color palette ColorPalProc(); //If background color is changed, let message fall through if(glColorChgAction==COLORCHANGE_BACKGROUND) { //Get color of text. lColor=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYTEXTCOLOR, MPVOID,MPVOID)); if(lColor==mp1) { sprintf(buffer,"Text color and background color may not be the same."); WinMessageBox(HWND_DESKTOP, hwndClient, buffer,szAppName,0, MB_OK|MB_ICONEXCLAMATION|MB_MOVEABLE); return 0; } else { //Set color change flag so color is not changed again. glColorChgAction=COLORCHANGE_CANCEL; break; } } //If text color is changed, change text color and return if(glColorChgAction==COLORCHANGE_TEXT) { //Get color of background. lColor=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYBACKCOLOR, MPVOID,MPVOID)); if(lColor==mp1) { sprintf(buffer,"Text color and background color may not be the same."); WinMessageBox(HWND_DESKTOP, hwndClient, buffer,szAppName,0, MB_OK|MB_ICONEXCLAMATION|MB_MOVEABLE); return 0; } else { WinSendMsg(hwndMLE, MLM_SETTEXTCOLOR, mp1, MPVOID); //Set color change flag so color is not changed again. glColorChgAction=COLORCHANGE_CANCEL; return 0; } } //Handle cancel if(glColorChgAction==COLORCHANGE_CANCEL) return 0; break; //MLM_SETBACKCOLOR case WM_CHAR: //Set enter key flag down for autoindent. if(!(CHARMSG(&msg)->fs & KC_KEYUP)) { switch(CHARMSG(&msg)->vkey) { case VK_ENTER: case VK_NEWLINE: bEnterKeyDown=TRUE; break; } } //Let autosave know there was a modification if(CHARMSG(&msg)->fs & KC_KEYUP) { iRes=AutoSaveModProc(AUTOSAVEMOD_INCREMENT); } //Handle key status changes - caps lock, num lock, insert if(CHARMSG(&msg)->fs & KC_KEYUP) if(CHARMSG(&msg)->fs & KC_VIRTUALKEY) switch(CHARMSG(&msg)->vkey) { case VK_PAGEUP: break; case VK_UP: break; case VK_ENTER: case VK_NEWLINE: if(bEnterKeyDown) { if(bUseAutoIndent) iRes=AutoIndentProc(); } bEnterKeyDown=FALSE; break; case VK_INSERT: case VK_CAPSLOCK: case VK_NUMLOCK: if (bStatusBarOn) UpdateKeyStatus(); //in status.c break; } case WM_BUTTON1CLICK: if (bStatusBarOn) { //Update line display in status window ipt=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYSEL, MPFROMSHORT(MLFQS_CURSORSEL), MPVOID)); lGlobalCurrentLine=LONGFROMMR(WinSendMsg(hwndMLE, MLM_LINEFROMCHAR, MPFROMLONG(ipt), MPVOID))+1; //Get start of current line iptLineStart=LONGFROMMR(WinSendMsg(hwndMLE, MLM_CHARFROMLINE, MPFROMLONG(-1L), //MPFROMLONG(lGlobalCurrentLine), MPVOID)); //Get total length of line iptTotalLineLength=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYLINELENGTH, MPFROMLONG(iptLineStart), MPVOID)); //Get length from cursor to end of line iptCursorToEndLength=LONGFROMMR(WinSendMsg(hwndMLE, MLM_QUERYLINELENGTH, MPFROMLONG(-1L), MPVOID)); //Calculate current column lGlobalCurrentColumn=iptTotalLineLength-iptCursorToEndLength+1; //Update status window if line or column has changed if ( (lCurrentColumn!=lGlobalCurrentColumn) || (lCurrentLine!=lGlobalCurrentLine) ) UpdateStatusWindow(); //store curren line and column lCurrentColumn=lGlobalCurrentColumn; lCurrentLine=lGlobalCurrentLine; } //end if bStatusBarOn break; ///////////////////////////////////////////////////// //Real-time vertical scrolling case WM_VSCROLL: if(iFirstVScroll==0) { //Get scroll bar ID idVScroll=SHORT1FROMMP(mp1); //Get handle of scroll vertical scroll bar. hwndVScroll=WinWindowFromID(hwndMLE,idVScroll); //Get scroll bar range. mres=WinSendMsg(hwndVScroll, SBM_QUERYRANGE, MPVOID,MPVOID); sScrollBarFirst=SHORT1FROMMR(mres); sScrollBarLast=SHORT2FROMMR(mres); sScrollBarRange=sScrollBarLast-sScrollBarFirst; iFirstVScroll=1; } if (SHORT2FROMMP(mp2)==SB_ENDSCROLL) break; switch (SHORT2FROMMP(mp2)) { case SB_SLIDERTRACK: //Send message to fool MLE into thinking scroll has ended WinSendMsg(hwndMLE, WM_VSCROLL, mp1, MPFROMLONG( MAKELONG( SHORT1FROMMP(mp2), SB_SLIDERPOSITION ) )); WinSendMsg(hwndMLE, WM_VSCROLL, mp1, MPFROMLONG( MAKELONG( SHORT1FROMMP(mp2), SB_ENDSCROLL ) )); break; } //Invalidate scroll paint area. WinInvalidateRect(hwndVScroll,NULL,TRUE); //Force update of scroll bar WinUpdateWindow(hwndVScroll); break;//WM_VSCROLL ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// //Real-time horizontal scrolling. case WM_HSCROLL: if(iFirstHScroll==0) { //Get scroll bar ID idHScroll=SHORT1FROMMP(mp1); //Get handle of scroll vertical scroll bar. hwndHScroll=WinWindowFromID(hwndMLE,idHScroll); iFirstHScroll=1; } if (SHORT2FROMMP(mp2)==SB_ENDSCROLL) break; switch (SHORT2FROMMP(mp2)) { case SB_SLIDERTRACK: //Send message to fool MLE into thinking scroll has ended WinSendMsg(hwndMLE, WM_HSCROLL, mp1, MPFROMLONG( MAKELONG( SHORT1FROMMP(mp2), SB_SLIDERPOSITION ) )); WinSendMsg(hwndMLE, WM_HSCROLL, mp1, MPFROMLONG( MAKELONG( SHORT1FROMMP(mp2), SB_ENDSCROLL ) )); break; } //Invalidate scroll paint area. WinInvalidateRect(hwndHScroll,NULL,TRUE); //Force update of scroll bar WinUpdateWindow(hwndHScroll); break; //WM_HSCROLL ///////////////////////////////////////////////////// } return MLEDefProc(hwnd,msg,mp1,mp2); }
/*! \brief Get an item \author Unknow, revamped by Endymion \param client the client */ void get_item( NXWCLIENT client ) // Client grabs an item { if ( client == NULL) return; P_CHAR pc_currchar = client->currChar(); VALIDATEPC( pc_currchar ); NXWSOCKET s = client->toInt(); P_ITEM pi = pointers::findItemBySerPtr(buffer[s]+1); VALIDATEPI(pi); //Luxor: not-movable items /*if (pi->magic == 2 || (isCharSerial(pi->getContSerial()) && pi->getContSerial() != pc_currchar->getSerial32()) ) { if (isCharSerial(pi->getContSerial())) { P_CHAR pc_i = pointers::findCharBySerial(pi->getContSerial()); if (ISVALIDPC(pc_i)) pc_i->sysmsg("Warning, backpack bug located!"); } if (client->isDragging()) { client->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; }*/ pc_currchar->disturbMed(); // Meditation tile_st item; data::seekTile( pi->getId(), item ); // Check if item is equiped if( pi->getContSerial() == pc_currchar->getSerial32() && pi->layer == item.quality ) { if( pc_currchar->UnEquip( pi, 1 ) == 1 ) // bypass called { if( client->isDragging() ) { UI08 cmd[1]= {0x29}; client->resetDragging(); Xsend(s, cmd, 1); UpdateStatusWindow(s,pi); //AoS/ Network->FlushBuffer(s); } return; } } P_CHAR owner=NULL; P_ITEM container=NULL; if ( !pi->isInWorld() ) { // Find character owning item if ( isCharSerial( pi->getContSerial())) { owner = pointers::findCharBySerial( pi->getContSerial()); } else // its an item { //Endymion Bugfix: //before check the container.. but if this cont is a subcont? //so get the outmostcont and check it else: //can loot without lose karma in subcont //can steal in trade ecc //not very good :P container = pi->getOutMostCont(); if( isCharSerial( container->getContSerial() ) ) owner=pointers::findCharBySerial( container->getContSerial() ); } if ( ISVALIDPC( owner ) && owner->getSerial32()!=pc_currchar->getSerial32() ) { if ( !pc_currchar->IsGM() && owner->getOwnerSerial32() != pc_currchar->getSerial32() ) {// Own serial stuff by Zippy -^ Pack aniamls and vendors. UI08 bounce[2]= { 0x27, 0x00 }; Xsend(s, bounce, 2); //AoS/ Network->FlushBuffer(s); if (client->isDragging()) { client->resetDragging(); pi->setContSerial(pi->getContSerial(),true,false); item_bounce3(pi); UpdateStatusWindow(s,pi); } return; } } } if ( ISVALIDPI( container ) ) { if ( container->layer == 0 && container->getId() == 0x1E5E) { // Trade window??? SERIAL serial = calcserial( pi->moreb1, pi->moreb2, pi->moreb3, pi->moreb4); if ( serial == INVALID ) return; P_ITEM piz = pointers::findItemBySerial(serial ); if ( ISVALIDPI( piz ) ) if ( piz->morez || container->morez ) { piz->morez = 0; container->morez = 0; sendtradestatus( piz, container ); } //<Luxor> if (pi->amxevents[EVENT_ITAKEFROMCONTAINER]!=NULL) { g_bByPass = false; pi->amxevents[EVENT_ITAKEFROMCONTAINER]->Call( pi->getSerial32(), pi->getContSerial(), pc_currchar->getSerial32() ); if (g_bByPass) { Sndbounce5(s); if (client->isDragging()) { client->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } } //</Luxor> /* //<Luxor> g_bByPass = false; pi->runAmxEvent( EVENT_ITAKEFROMCONTAINER, pi->getSerial32(), pi->getContSerial(), s ); if (g_bByPass) { Sndbounce5(s); if (client->isDragging()) { client->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } //</Luxor> */ if ( container->corpse ) { if ( container->getOwnerSerial32() != pc_currchar->getSerial32()) { //Looter :P pc_currchar->unHide(); bool bCanLoot = false; if( pc_currchar->party!=INVALID ) { P_CHAR dead = pointers::findCharBySerial( container->getOwnerSerial32() ) ; if( ISVALIDPC( dead ) && dead->party==pc_currchar->party ) { P_PARTY party = Partys.getParty( pc_currchar->party ); if( party!=NULL ) { P_PARTY_MEMBER member = party->getMember( pc_currchar->getSerial32() ); if( member!=NULL ) bCanLoot = member->canLoot; } } } if ( !bCanLoot && container->more2==1 ) { pc_currchar->IncreaseKarma(-5); setCrimGrey(pc_currchar, ServerScp::g_nLootingWillCriminal); pc_currchar->sysmsg( TRANSLATE("You are loosing karma!")); } } } // corpse stuff container->SetMultiSerial(INVALID); //at end reset decay of container container->setDecayTime(); } // end cont valid } if ( !pi->corpse ) { UpdateStatusWindow(s, pi); tile_st tile; data::seekTile( pi->getId(), tile); if (!pc_currchar->IsGM() && (( pi->magic == 2 || ((tile.weight == 255) && ( pi->magic != 1))) && !pc_currchar->canAllMove() ) || (( pi->magic == 3|| pi->magic == 4) && !pc_currchar->isOwnerOf( pi ))) { UI08 bounce[2]={ 0x27, 0x00 }; Xsend(s, bounce, 2); //AoS/ Network->FlushBuffer(s); if (client->isDragging()) // only restore item if it got draggged before !!! { client->resetDragging(); item_bounce4(s, pi ); } } // end of can't get else { // AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing ) client->setDragging(); pi->setOldPosition( pi->getPosition() ); // first let's save the position pi->oldlayer = pi->layer; // then the layer pi->layer = 0; if (!pi->isInWorld()) pc_currchar->playSFX(0x0057); if (pi->amount>1) { UI16 amount = ShortFromCharPtr(buffer[s] +5); if (amount > pi->amount) amount = pi->amount; else if (amount < pi->amount) { //get not all but a part of item ( piled? ), but anyway make a new one item P_ITEM pin =archive::item::New(); (*pin)=(*pi); pin->amount = (UI16)( pi->amount - amount); pin->setContSerial(pi->getContSerial()); //Luxor pin->setPosition( pi->getPosition() ); /*if( !pin->isInWorld() && isItemSerial( pin->getContSerial() ) ) pin->SetRandPosInCont( (P_ITEM)pin->getContainer() );*/ if ( pin->getOwnerSerial32() != INVALID ) pin->setOwnerSerial32( pi->getOwnerSerial32() ); statwindow(pc_currchar,pc_currchar); pin->Refresh();//AntiChrist } if ( pi->getId() == ITEMID_GOLD) { P_ITEM pack= pc_currchar->getBackpack(); if (ISVALIDPI(pack)) // lb if ( pi->getContSerial() == pack->getSerial32()) statwindow(pc_currchar, pc_currchar); } pi->amount = amount; } // end if corpse #ifdef SPAR_I_LOCATION_MAP pointers::delFromLocationMap( pi ); #else mapRegions->remove( pi ); #endif pi->setPosition( 0, 0, 0 ); pi->setContSerial( INVALID, false ); } } int amt = 0, wgt; if ( container == NULL ) { wgt = (int)weights::LockeddownWeight( pi, &amt); pc_currchar->weight += wgt; statwindow(pc_currchar, pc_currchar); } }
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; } } }
/* * goToLine - go to a specified line number */ static vi_rc goToLine( linenum lineno, bool relcurs ) { int text_lines, tl; linenum diff, cwl, nwl; // linenum s, e, hiddcnt; bool dispall, pageshift; fcb *cfcb; line *cline; int pad; vi_rc rc; if( lineno < 1 ) { return( ERR_NO_SUCH_LINE ); } /* * get pointer to requested line */ rc = CGimmeLinePtr( lineno, &cfcb, &cline ); if( rc != ERR_NO_ERR ) { return( rc ); } #if 0 if( cline->u.ld.hidden ) { GetHiddenRange( lineno, &s, &e ); if( lineno > CurrentPos.line ) { lineno = e + 1; } else { lineno = s - 1; } rc = CGimmeLinePtr( lineno, &cfcb, &cline ); if( rc != ERR_NO_ERR ) { return( rc ); } } #endif /* * compute new location */ CurrentFcb = cfcb; CurrentLine = cline; diff = lineno - CurrentPos.line; if( diff == 0 && !EditFlags.GlobalInProgress ) { return( ERR_NO_ERR ); } cwl = CurrentPos.line - LeftTopPos.line + 1; nwl = cwl + diff; /* * if we go off the window, relocate */ pageshift = false; dispall = false; text_lines = WindowAuxInfo( current_window_id, WIND_INFO_TEXT_LINES ); if( nwl < 1 || nwl > text_lines ) { tl = text_lines / 2; if( !relcurs ) { LeftTopPos.line = lineno - tl; } else { LeftTopPos.line = lineno + 1 - cwl; pad = ( EditFlags.JumpyScroll ) ? 1 : 0; if( diff > 0 ) { LeftTopPos.line += pad; diff += pad; } else { LeftTopPos.line -= pad; diff -= pad; } if( diff > -tl && diff < tl && !dispall ) { pageshift = true; } } if( LeftTopPos.line < 1 ) { assert( diff <= 0 ); // < -> <= W.Briscoe 20031003 to avoid debug build failure of // C:\watcom\source\docs\nt) wmake -h -f ..\mif\master.mif hbook=wccerrs dotarget=nt diff += ( 1 - LeftTopPos.line ); LeftTopPos.line = 1; } if( LeftTopPos.line > lineno ) { assert( diff > 0 ); diff = LeftTopPos.line - lineno; LeftTopPos.line = lineno; } dispall = true; } #if 0 hiddcnt = GetHiddenLineCount( LeftTopPos.line, lineno ); if( hiddcnt > 0 ) { pageshift = false; dispall = true; } #endif if( CheckCurrentColumn() || EditFlags.Dragging ) { // pageshift wont help if we also have to column shift // and not really useful if dragging dispall = true; pageshift = false; } /* call SetCurrentLineNumber AFTER LeftTopPos.line set & CurrentColumn checked */ SetCurrentLineNumber( lineno ); if( pageshift ) { dispall = false; ShiftWindowUpDown( current_window_id, diff ); if( EditFlags.LineNumbers ) { ShiftWindowUpDown( curr_num_window_id, diff ); } if( diff > 0 ) { DCDisplaySomeLines( text_lines - diff, text_lines - 1 ); } else { DCDisplaySomeLines( 0, -diff - 1 ); } } UpdateStatusWindow(); SetWindowCursor(); if( dispall ) { DCInvalidateAllLines(); // lines definitely invalid DCDisplayAllLines(); } return( ERR_NO_ERR ); } /* goToLine */
void get_item(P_CLIENT ps) // Client grabs an item { int x, npc=-1, c, amount, update = 0, serial; // tile_st tile; int z;// antichrist for trade fix UOXSOCKET s = ps->GetSocket(); int cc = ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LR(cc); serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]); if (serial == INVALID_SERIAL || buffer[s][1] < 0x40) return; // landscape or a character P_ITEM pi = FindItemBySerial(serial); if (pi == NULL) return; pc_currchar->disturbMed(s); // Meditation // Zippy's stealing changes x = DEREF_P_ITEM(pi); if (!items[x].isInWorld()) // Find character owning item { int loopexit = 0; do // Find character owning item { if (isCharSerial(items[x].contserial)) { npc = calcCharFromSer(items[x].contserial); } else // its an item { if (items[x].isInWorld()) { npc=-1; break; } x = calcItemFromSer(items[x].contserial); // ANTICHRIST -- SECURE TRADE FIX if (x!=-1) // LB overwriting x is essential here, dont change it!!! { if (items[x].layer == 0 && items[x].id() == 0x1E5E) { // Trade window??? serial = calcserial(items[x].moreb1, items[x].moreb2, items[x].moreb3, items[x].moreb4); if (serial == INVALID_SERIAL) return; z = calcItemFromSer(serial); if (z!=-1) if ((items[z].morez || items[x].morez)) { items[z].morez = 0; items[x].morez = 0; sendtradestatus(z, x); } } // Blackwinds Looting is crime implementation // changed slightly by Ripper if (items[x].corpse != 0 && !pc_currchar->Owns(&items[x])) { P_CHAR co = FindCharBySerial(items[x].ownserial); if (items[x].more2 == 1 && Guilds->Compare(cc, DEREF_P_CHAR(co)) == 0) { pc_currchar->karma -= 5; criminal(cc); sysmessage(s, "You lost some karma!"); } npc = 0; } // Criminal stuff if (items[x].corpse != 0) npc = 0; } // end if x!=-1 if (x==-1) npc = 0; } } while ((npc==-1) &&(++loopexit < MAXLOOPS)); } if (npc>0) // 0=corpse, hence >0 .. { if (!(pc_currchar->isGM()) && npc != cc && ! pc_currchar->Owns(&chars[npc])) {// Own serial stuff by Zippy -^ Pack aniamls and vendors. bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce3(pi); pi->magic = 3; } return; } } // End Zippy's change // Boats-> if (x!=-1 && npc!=-1) { if (items[x].multis>0) imultisp.remove(items[x].multis, items[x].serial); items[x].startDecay(); // End Boats Change // AntiChrist -- for poisoned items if (items[x].layer>0) { chars[npc].removeItemBonus(&items[x]); // remove BONUS STATS given by equipped special items } if ((items[x].trigon==1) && (items[x].layer != 0) && (items[x].layer != 15) && (items[x].layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *- { triggerwitem(s, DEREF_P_ITEM(pi), 1); // trigger is fired } // AntiChrist -- for poisoned items if (items[x].poisoned) { chars[npc].poison -= items[x].poisoned; if (chars[npc].poison < 0) chars[npc].poison = 0; } } if (pi != NULL) { if (pi->corpse != 1) { UpdateStatusWindow(s, pi); if (!pc_currchar->canPickUp(pi)) { bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) // only restore item if it got draggged before !!! { ps->ResetDragging(); item_bounce4(s, pi); } } else { // AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing ) DRAGGED[s] = 1; pi->oldx = pi->pos.x; // first let's save the position pi->oldy = pi->pos.y; pi->oldz = pi->pos.z; pi->oldcontserial = pi->contserial; // then let's save the container pi->oldlayer = pi->layer; // then the layer pi->layer = 0; if (!pi->isInWorld()) soundeffect(s, 0x00, 0x57); if (pi->amount>1) { amount = (buffer[s][5] << 8) + buffer[s][6]; if (amount>pi->amount) amount = pi->amount; if (amount < pi->amount) { c=Items->MemItemFree(); items[c].Init(0); memcpy(&items[c], pi, sizeof(cItem)); // Tauriel reduce code faster too items[c].SetSerial(itemcount2); itemcount2++; items[c].amount = pi->amount - amount; // Tauriel sorry, there is no way to make this call the item creation stuff // Why doing it twice? // setptr(&itemsp[itemcount2%HASHMAX], c); // itemcount2++; // important bugfix for items disappearing, lb if (!items[c].isInWorld()) contsp.insert(items[c].contserial, items[c].serial); if (items[c].ownserial!=-1) setptr(&ownsp[items[c].ownserial%HASHMAX], c); if (items[c].spawnserial!=-1) setptr(&spawnsp[items[c].spawnserial%HASHMAX], c); statwindow(s,cc); RefreshItem(c);//AntiChrist } if (pi->id() == 0x0EED) // gold coin { int packnum = packitem(currchar[s]); if (packnum!=-1) // lb if (pi->contserial == items[packnum].serial) update = 1; } pi->amount = amount; } // Tauriel remove item from world mapcells mapRegions->Remove(pi); // remove this item from a map cell pi->pos.x = 0; pi->pos.y = 0; pi->pos.z = 0; pi->flags.isBeeingDragged=true; pi->SetContSerial(-1); if (pi != NULL) // Ripper...adds weight to the players cursor when carrying a item. { int amt = 0, wgt; wgt = (int)Weight->LockeddownWeight(pi, &amt, 0); pc_currchar->weight += wgt; update = 1; } } } } // end of if i!=-1 if (update) statwindow(s, DEREF_P_CHAR(pc_currchar)); }
/* * MovePage - move by a number of pages */ vi_rc MovePage( int dir, long repcnt, bool keepselect ) { vi_rc rc; linenum x, top, ll; linenum tmp; if( EditFlags.Modeless && !keepselect ) { UnselectRegion(); } tmp = (repcnt * dir * WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES )) - (dir * EditVars.PageLinesExposed); #if 0 x = CurrentPos.line + tmp; top = LeftTopPos.line + tmp; CFindLastLine( &ll ); if( top > ll ) { top = ll; } else if( top < 1 ) { top = 1; } if( x > ll ) { x = ll; } else if( x < 1 ) { x = 1; } #else top = LeftTopPos.line + tmp; if( top < 1 ) { top = 1; } rc = CAdvanceToLine( top ); if( rc == ERR_NO_SUCH_LINE ) { rc = CFindLastLine( &ll ); top = ll; } if( rc != ERR_NO_ERR ) { return( rc ); } x = CurrentPos.line + tmp; if( x < 1 ) { x = 1; } rc = CAdvanceToLine( x ); if( rc == ERR_NO_SUCH_LINE ) { rc = CFindLastLine( &ll ); x = ll; } if( rc != ERR_NO_ERR ) { return( rc ); } #endif LeftTopPos.line = top; SetCurrentLineNumber( x ); rc = CGimmeLinePtr( CurrentPos.line, &CurrentFcb, &CurrentLine ); if( rc == ERR_NO_ERR ) { CheckCurrentColumn(); UpdateStatusWindow(); SetWindowCursor(); DCInvalidateAllLines(); DCDisplayAllLines(); } return( rc ); } /* MovePage */
/* * NewFile - load up a new file */ vi_rc NewFile( char *name, bool same_file ) { vi_rc rc; bool dup; status_type oldstatus; dup = EditFlags.DuplicateFile; EditFlags.DuplicateFile = false; oldstatus = UpdateCurrentStatus( CSTATUS_READING ); ScreenPage( 1 ); #ifdef __WIN__ EditFlags.ResizeableWindow = true; #endif rc = createNewFile( name, same_file ); if( rc != ERR_NO_ERR && rc != NEW_FILE ) { ScreenPage( -1 ); if( !EditFlags.Starting ) { MoveWindowToFrontDammit( MessageWindow, true ); MoveWindowToFrontDammit( CurrentWindow, true ); } UpdateCurrentStatus( oldstatus ); return( rc ); } GoToLineNoRelCurs( 1 ); GoToColumnOnCurrentLine( 1 ); FileSPVAR(); SaveCurrentInfo(); if( !same_file ) { inReadHook++; rc = SourceHook( SRC_HOOK_READ, rc ); inReadHook--; } /* * back from hook, so all loadings are done * (who should have priority - hook or fts commands?) */ #if 0 rc = FTSRunCmds( CurrentFile->name ); FTSRunCmds( CurrentFile->name ); #endif /* * reset the screen to the display page, display everything */ ScreenPage( -1 ); MoveWindowToFrontDammit( CurrentWindow, true ); UpdateStatusWindow(); SetWindowCursor(); DCDisplayAllLines(); EditFlags.DuplicateFile = dup; DisplayFileStatus(); SaveCurrentInfo(); ActiveWindow( CurrentWindow ); VarAddRandC(); SetModifiedVar( false ); UpdateCurrentStatus( oldstatus ); if( !same_file && !inReadHook ) { UpdateLastFileList( CurrentFile->name ); } #ifdef __WIN__ DCUpdateAll(); ResetEditWindowCursor( CurrentWindow ); SetWindowCursorForReal(); GotoFile( CurrentWindow ); #endif return( rc ); } /* NewFile */
void cDragdrop::get_item(P_CLIENT ps) // Client grabs an item { int npc=-1, amount, update = 0, serial; UOXSOCKET s = ps->GetSocket(); int cc = ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LR(cc); serial = calcserial(buffer[s][1], buffer[s][2], buffer[s][3], buffer[s][4]); if (serial == INVALID_SERIAL || buffer[s][1] < 0x40) return; // landscape or a character P_ITEM pi = FindItemBySerial(serial); if (pi == NULL) return; pc_currchar->disturbMed(s); // Meditation // Zippy's stealing changes P_ITEM px = pi; if (!px->isInWorld()) // Find character owning item { unsigned long loopexit = 0; do // Find character owning item { if (isCharSerial(px->contserial)) { npc = calcCharFromSer(px->contserial); } else // its an item { if (px->isInWorld()) { npc=-1; break; } px = FindItemBySerial(px->contserial); // ANTICHRIST -- SECURE TRADE FIX if (px != NULL) // LB overwriting x is essential here, dont change it!!! { if (px->layer == 0 && px->id() == 0x1E5E) { // Trade window??? serial = calcserial(px->moreb1, px->moreb2, px->moreb3, px->moreb4); if (serial == INVALID_SERIAL) return; P_ITEM pi_z = FindItemBySerial(serial); if ( pi_z != NULL ) if ((pi_z->morez || px->morez)) { pi_z->morez = 0; px->morez = 0; sendtradestatus(pi_z, px); } } // Blackwinds Looting is crime implementation // changed slightly by Ripper if (px->corpse != 0 && !pc_currchar->Owns(px)) { P_CHAR co = FindCharBySerial(px->ownserial); if (px->more2 == 1 && Guilds->Compare(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(co)) == 0) { pc_currchar->karma -= 5; criminal(DEREF_P_CHAR(pc_currchar)); sysmessage(s, "You lost some karma!"); } npc = 0; } // Criminal stuff if (px->corpse != 0) npc = 0; } // end if x!=-1 if (px == NULL) npc = 0; } } while ((npc==-1) &&(++loopexit < MAXLOOPS)); } if (npc>0) // 0=corpse, hence >0 .. { if (!(pc_currchar->isGM()) && npc != DEREF_P_CHAR(pc_currchar) && ! pc_currchar->Owns(&chars[npc])) {// Own serial stuff by Zippy -^ Pack aniamls and vendors. bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce3(pi); pi->magic = 3; } return; } } // End Zippy's change // Boats-> if (px != NULL && npc!=-1) { if (px->multis>0) imultisp.remove(px->multis, px->serial); px->startDecay(); // End Boats Change // AntiChrist -- for poisoned items if (px->layer>0) { chars[npc].removeItemBonus(px); // remove BONUS STATS given by equipped special items } if ((px->trigon==1) && (px->layer != 0) && (px->layer != 15) && (px->layer < 19))// -Frazurbluu- Trigger Type 2 is my new trigger type *- { Trig->triggerwitem(s, pi, 1); // trigger is fired } } if (pi != NULL) { if (pi->corpse != 1) { UpdateStatusWindow(s, pi); if (!pc_currchar->canPickUp(pi)) { bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) // only restore item if it got draggged before !!! { ps->ResetDragging(); item_bounce4(s, pi); } } else { // AntiChrist bugfix for the bad bouncing bug ( disappearing items when bouncing ) DRAGGED[s] = 1; pi->oldx = pi->pos.x; // first let's save the position pi->oldy = pi->pos.y; pi->oldz = pi->pos.z; pi->oldcontserial = pi->contserial; // then let's save the container pi->oldlayer = pi->layer; // then the layer pi->layer = 0; if (!pi->isInWorld()) soundeffect(s, 0x00, 0x57); if (pi->amount>1) { amount = (buffer[s][5] << 8) + buffer[s][6]; if (amount>pi->amount) amount = pi->amount; if (amount < pi->amount) { P_ITEM pi_c = Items->MemItemFree(); // pi_c->Init(0); #pragma note("Replace by a copy constructor before finishing items[]") memcpy(pi_c, pi, sizeof(cItem)); // Tauriel reduce code faster too pi_c->SetSerial(cItemsManager::getItemsManager().getUnusedSerial()); pi_c->amount = pi->amount - amount; pi_c->SetContSerial(pi_c->contserial); pi_c->SetOwnSerial(pi_c->ownserial); pi_c->SetSpawnSerial(pi_c->spawnserial); statwindow(s,DEREF_P_CHAR(pc_currchar)); RefreshItem(pi_c);//AntiChrist } if (pi->id() == 0x0EED) // gold coin { P_ITEM packnum = packitem(currchar[s]); if (packnum != NULL) // lb if (pi->contserial == packnum->serial) update = 1; } pi->amount = amount; } /* int amt = 0, wgt; bool tooheavy=false; wgt = (int)Weight->LockeddownWeight(pi, &amt, 0); if(pi->contserial>0) { if (( (pc_currchar->weight+wgt) > (pc_currchar->st*WEIGHT_PER_STR)+30)) // LB -> added: drop item if too heavy { float res=float( (pc_currchar->weight+wgt) - ((pc_currchar->st*WEIGHT_PER_STR)+30))*2; int diff = pc_currchar->st; diff -= (int)res; if (diff<=0 && !pc_currchar->isGM() ) { tooheavy=true; bounce[1] = 0; Xsend(s, bounce, 2); if (ps->IsDragging()) // only restore item if it got dragged before !!! { ps->ResetDragging(); item_bounce4(s, pi); } sysmessage(s, "you can't pick this up, this is too heavy"); return; } } } if (!tooheavy) pc_currchar->weight+=wgt; update = 1; */ // LB remark: drop item if too heavy is a good solution, // but there's still a small bug remaining. // added weight from items picked up, but not put to bp, pd, in other words hold in ones hand, // is NOT subtracted when being dropped again to ground/other chars/other chars' bp's. // but this bug doesnt show up becasue weight is re-calculated automatically all 10 secs. // without adding weight of the item curently carrying in hand. // a correct solutions need the weight of item in hand being stored // , added to auto-re-calculation all x-secs code, and being subtracted if dropped. // because it's now only happening for leight weight items, because heavy weight itms cant be picke up anymore // I haven't corrected this yet. // Tauriel remove item from world mapcells mapRegions->Remove(pi); // remove this item from a map cell pi->pos.x = 0; pi->pos.y = 0; pi->pos.z = 0; pi->flags.isBeeingDragged=true; pi->SetContSerial(-1); } } } // end of if i!=-1 if (update) statwindow(s, DEREF_P_CHAR(pc_currchar)); }
/* * processSetToken - set value for set token */ static vi_rc processSetToken( int j, char *value, int *winflag, bool isnonbool ) { char fn[MAX_STR], str[MAX_STR]; #ifndef VICOMP char tmp[3]; char settokstr[TOK_MAX_LEN + 1]; char save[MAX_STR]; vi_rc rc = ERR_NO_ERR; int i, clr, k; bool newset; bool set1, toggle, *ptr; jmp_buf jmpaddr; cursor_type ct; char *name; command_rtn fptr; event_bits eb; bool redisplay = FALSE; #endif bool bvalue; #ifdef VICOMP winflag = winflag; isnonbool = isnonbool; #endif /* * set up value for boolean set commands */ if( j < 0 ) { j *= -1; bvalue = FALSE; } else { bvalue = TRUE; } #ifndef VICOMP if( !(*winflag) ) { toggle = TRUE; set1 = isnonbool; } else { toggle = FALSE; #endif if( j >= SET1_T_ ) { #ifndef VICOMP if( EditFlags.CompileScript ) { #endif if( !bvalue ) { j *= -1; } itoa( j, str, 10 ); StrMerge( 2, WorkLine->data, str, SingleBlank ); return( ERR_NO_ERR ); #ifndef VICOMP } set1 = FALSE; j -= SET1_T_; } else { set1 = TRUE; #endif } #ifndef VICOMP } *winflag = FALSE; /* * process boolean settings */ if( !set1 ) { if( j >= SET2_T_ ) { return( ERR_INVALID_SET_COMMAND ); } ptr = &(((bool *)&EditFlags)[j]); newset = bvalue; if( toggle ) { newset = !(*ptr); } switch( j ) { case SET2_T_MODELESS: if( (newset && !EditFlags.Modeless) || (!newset && EditFlags.Modeless) ) { for( k = 0; k < MAX_EVENTS; k++ ) { fptr = EventList[k].rtn; eb = EventList[k].b; EventList[k].rtn = EventList[k].alt_rtn; EventList[k].alt_rtn = fptr; EventList[k].b = EventList[k].alt_b; EventList[k].alt_b = eb; } if( !EditFlags.Modeless ) { if( MenuWindow != NO_WINDOW ) { UpdateCurrentStatus( CSTATUS_INSERT ); } EditFlags.WasOverstrike = FALSE; NewCursor( CurrentWindow, EditVars.InsertCursorType ); } else { if( MenuWindow != NO_WINDOW ) { UpdateCurrentStatus( CSTATUS_COMMAND ); } NewCursor( CurrentWindow, EditVars.NormalCursorType ); // nomodeless must be line based or it dies! EditFlags.LineBased = TRUE; } /* re-position cursor in window */ SetWindowCursor(); } EditFlags.Modeless = newset; break; case SET2_T_UNDO: if( EditFlags.Undo && !newset ) { FreeAllUndos(); } EditFlags.Undo = newset; break; case SET2_T_STATUSINFO: EditFlags.StatusInfo = newset; #ifdef __WIN__ ResizeRoot(); #endif rc = NewStatusWindow(); break; case SET2_T_WINDOWGADGETS: EditFlags.WindowGadgets = newset; ResetAllWindows(); *winflag = TRUE; redisplay = TRUE; break; case SET2_T_REALTABS: EditFlags.RealTabs = newset; redisplay = TRUE; break; case SET2_T_CLOCK: EditFlags.Clock = newset; redisplay = TRUE; break; case SET2_T_TOOLBAR: EditFlags.Toolbar = newset; #ifdef __WIN__ ResizeRoot(); #endif break; case SET2_T_COLORBAR: EditFlags.Colorbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.Colorbar = FALSE; } else { RefreshColorbar(); } #endif break; case SET2_T_SSBAR: EditFlags.SSbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.SSbar = FALSE; } else { RefreshSSbar(); } #endif break; case SET2_T_FONTBAR: EditFlags.Fontbar = newset; #ifdef __WIN__ if( Root == NULL ) { EditFlags.Fontbar = FALSE; } else { RefreshFontbar(); } #endif break; case SET2_T_MARKLONGLINES: EditFlags.MarkLongLines = newset; break; case SET2_T_MENUS: EditFlags.Menus = newset; InitMenu(); break; case SET2_T_LINENUMBERS: if( toggle ) { newset = !EditFlags.LineNumbers; } if( newset != EditFlags.LineNumbers ) { EditFlags.LineNumbers = newset; rc = LineNumbersSetup(); *winflag = TRUE; } break; case SET2_T_CURRENTSTATUS: EditFlags.CurrentStatus = newset; InitMenu(); break; case SET2_T_DISPLAYSECONDS: EditFlags.DisplaySeconds = newset; redisplay = TRUE; break; case SET2_T_PPKEYWORDONLY: EditFlags.PPKeywordOnly = newset; redisplay = TRUE; break; case SET2_T_LASTEOL: #ifndef __WIN__ *ptr = TRUE; toggle = FALSE; break; #endif default: *ptr = newset; break; } if( msgFlag ) { if( !newset ) { tmp[0] = 'n'; tmp[1] = 'o'; tmp[2] = 0; } else { tmp[0] = 0; } MySprintf( fn, "%s%s set", tmp, GetTokenStringCVT( SetTokens2, j, settokstr, TRUE ) ); } if( toggle ) { strcpy( save, BoolStr[(int) newset] ); (*winflag) += 1; } /* * process value settings */ } else { if( toggle ) { rc = GetNewValueDialog( value ); if( rc != ERR_NO_ERR ) { return( rc ); } strcpy( save, value ); } #endif /* VICOMP */ RemoveLeadingSpaces( value ); if( value[0] == '"' ) { NextWord( value, fn, "\"" ); EliminateFirstN( value, 1 ); } else { NextWord1( value, fn ); } #ifndef VICOMP if( EditFlags.CompileScript ) { #endif itoa( j, str, 10 ); strcat( WorkLine->data, str ); if( fn[0] == '\0' ) return( ERR_NO_ERR ); switch( j ) { case SET1_T_STATUSSTRING: case SET1_T_FILEENDSTRING: case SET1_T_HISTORYFILE: case SET1_T_TMPDIR: case SET1_T_TAGFILENAME: StrMerge( 4, WorkLine->data, SingleBlank, SingleQuote, fn, SingleQuote ); break; case SET1_T_COMMANDCURSORTYPE: case SET1_T_OVERSTRIKECURSORTYPE: case SET1_T_INSERTCURSORTYPE: StrMerge( 2, WorkLine->data, SingleBlank, fn ); if( NextWord1( value, fn ) <= 0 ) { break; } StrMerge( 2, WorkLine->data, SingleBlank, fn ); break; case SET1_T_TILECOLOR: StrMerge( 2, WorkLine->data, SingleBlank, fn ); if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } if( NextWord1( value, str ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } StrMerge( 4, WorkLine->data, fn, SingleBlank, str, SingleBlank ); break; case SET1_T_STATUSSECTIONS: StrMerge( 2, WorkLine->data, SingleBlank, fn ); while( NextWord1( value, fn ) > 0 ) { #ifdef VICOMP int k; #endif k = atoi( fn ); if( k <= 0 ) { break; } StrMerge( 2, WorkLine->data, SingleBlank, fn ); } break; default: StrMerge( 2, WorkLine->data, SingleBlank, fn ); break; } return( ERR_NO_ERR ); #ifndef VICOMP } switch( j ) { case SET1_T_STATUSSECTIONS: if( EditVars.StatusSections != NULL ) { MemFree( EditVars.StatusSections ); EditVars.StatusSections = NULL; EditVars.NumStatusSections = 0; } for( ;; ) { k = atoi( fn ); if( k <= 0 ) { break; } EditVars.StatusSections = MemReAlloc( EditVars.StatusSections, sizeof( short ) * (EditVars.NumStatusSections + 1) ); EditVars.StatusSections[EditVars.NumStatusSections] = k; EditVars.NumStatusSections++; if( NextWord1( value, fn ) <= 0 ) { break; } } if( EditVars.StatusSections == NULL ) { MySprintf( fn, "statussections turned off" ); } else { MySprintf( fn, "statussections set" ); } break; case SET1_T_FILEENDSTRING: AddString2( &EditVars.FileEndString, fn ); ResetAllWindows(); redisplay = TRUE; break; case SET1_T_STATUSSTRING: AddString2( &EditVars.StatusString, fn ); if( StatusWindow != NO_WINDOW ) { ClearWindow( StatusWindow ); UpdateStatusWindow(); } if( msgFlag ) { MySprintf( fn, "statusstring set to %s", EditVars.StatusString ); } break; case SET1_T_GREPDEFAULT: AddString2( &EditVars.GrepDefault, fn ); break; case SET1_T_TILECOLOR: if( EditVars.TileColors == NULL ) { EditVars.TileColors = (type_style *) MemAlloc( sizeof( type_style ) * ( EditVars.MaxTileColors + 1 ) ); for( i = 0; i <= EditVars.MaxTileColors; ++i ) { EditVars.TileColors[i].foreground = -1; EditVars.TileColors[i].background = -1; EditVars.TileColors[i].font = -1; } } clr = atoi( fn ); if( clr > EditVars.MaxTileColors ) { return( ERR_INVALID_SET_COMMAND ); } if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } EditVars.TileColors[clr].foreground = atoi( fn ); if( NextWord1( value, fn ) <= 0 ) { return( ERR_INVALID_SET_COMMAND ); } EditVars.TileColors[clr].background = atoi( fn ); EditVars.TileColors[clr].font = FONT_DEFAULT; if( msgFlag ) { MySprintf( fn, "tilecolor %d set", clr ); } break; case SET1_T_GADGETSTRING: SetGadgetString( fn ); if( msgFlag ) { MySprintf( fn, "gadget string set to %s", EditVars.GadgetString ); } ResetAllWindows(); break; case SET1_T_SHELLPROMPT: AddString2( &EditVars.SpawnPrompt, fn ); if( msgFlag ) { MySprintf( fn, "prompt string set to %s", EditVars.SpawnPrompt ); } break; case SET1_T_FIGNORE: if( fn[0] == 0 ) { MemFreePtr( (void **)&EditVars.FIgnore ); EditVars.CurrFIgnore = 0; if( msgFlag ) { MySprintf( fn, "fignore reset" ); } } else { EditVars.FIgnore = MemReAlloc( EditVars.FIgnore, EXTENSION_LENGTH * (EditVars.CurrFIgnore + 1) ); str[0] = '.'; str[1] = 0; strcat( str, fn ); str[EXTENSION_LENGTH - 1] = 0; strcpy( &EditVars.FIgnore[EXTENSION_LENGTH * EditVars.CurrFIgnore], str ); EditVars.CurrFIgnore++; if( msgFlag ) { MySprintf( fn, "%s added to fignore", str ); } } break; case SET1_T_HISTORYFILE: AddString2( &EditVars.HistoryFile, fn ); if( msgFlag ) { MySprintf( fn, "history file set to %s", EditVars.HistoryFile ); } break; case SET1_T_TAGFILENAME: AddString2( &EditVars.TagFileName, fn ); if( msgFlag ) { MySprintf( fn, "tag file name set to %s", EditVars.TagFileName ); } break; case SET1_T_FILENAME: if( CurrentFile != NULL ) { AddString2( &(CurrentFile->name), fn ); SetFileWindowTitle( CurrentWindow, CurrentInfo, TRUE ); if( msgFlag ) { MySprintf( fn, "filename set to %s", CurrentFile->name ); } FileSPVAR(); } break; case SET1_T_TMPDIR: AddString2( &EditVars.TmpDir, fn ); VerifyTmpDir(); if( msgFlag ) { MySprintf( fn, "tmpdir set to %s", EditVars.TmpDir ); } break; case SET1_T_WORD: AddString2( &EditVars.WordDefn, fn ); InitWordSearch( EditVars.WordDefn ); if( msgFlag ) { MySprintf( fn, "word set to %s", EditVars.WordDefn ); } break; case SET1_T_WORDALT: AddString2( &EditVars.WordAltDefn, fn ); if( msgFlag ) { MySprintf( fn, "wordalt set to %s", EditVars.WordAltDefn ); } break; case SET1_T_MAGICSTRING: AddString2( &EditVars.Majick, fn ); if( msgFlag ) { MySprintf( fn, "magicstring set to %s", EditVars.Majick ); } break; case SET1_T_COMMANDCURSORTYPE: case SET1_T_OVERSTRIKECURSORTYPE: case SET1_T_INSERTCURSORTYPE: i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); ct.height = GetConstExpr(); if( NextWord1( value, fn ) <= 0 ) { ct.width = 100; } else { i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); ct.width = GetConstExpr(); } if( j == SET1_T_COMMANDCURSORTYPE ) { EditVars.NormalCursorType = ct; name = "command"; } else if( j == SET1_T_OVERSTRIKECURSORTYPE ) { EditVars.OverstrikeCursorType = ct; name = "overstrike"; } else { EditVars.InsertCursorType = ct; name = "insert"; } if( msgFlag ) { MySprintf( fn, "%s cursor type set to %d,%d", name, ct.height, ct.width ); } break; default: i = setjmp( jmpaddr ); if( i != 0 ) { return( ERR_INVALID_SET_COMMAND ); } StartExprParse( fn, jmpaddr ); i = GetConstExpr(); if( i < 0 ) { i = 0; } switch( j ) { case SET1_T_WRAPMARGIN: EditVars.WrapMargin = i; break; case SET1_T_CURSORBLINKRATE: SetCursorBlinkRate( i ); break; case SET1_T_MAXPUSH: EditVars.MaxPush = i; if( EditVars.MaxPush < 1 ) { EditVars.MaxPush = 1; } InitFileStack(); break; case SET1_T_RADIX: EditVars.Radix = i; break; case SET1_T_AUTOSAVEINTERVAL: EditVars.AutoSaveInterval = i; SetNextAutoSaveTime(); break; case SET1_T_LANGUAGE: if( i < LANG_NONE || i >= LANG_MAX ) { return( ERR_INVALID_SET_COMMAND ); } if( CurrentInfo != NULL ) { LangFini( CurrentInfo->fsi.Language ); LangInit( i ); redisplay = TRUE; } break; case SET1_T_MOVECOLOR: EditVars.MoveColor = i; break; case SET1_T_RESIZECOLOR: EditVars.ResizeColor = i; break; case SET1_T_MOUSEDCLICKSPEED: EditVars.MouseDoubleClickSpeed = i; break; case SET1_T_MOUSESPEED: SetMouseSpeed( i ); break; case SET1_T_MOUSEREPEATDELAY: EditVars.MouseRepeatDelay = i; break; case SET1_T_CURRENTSTATUSCOLUMN: EditVars.CurrentStatusColumn = i; InitMenu(); break; case SET1_T_ENDOFLINECHAR: EditVars.EndOfLineChar = i; break; case SET1_T_EXITATTR: EditVars.ExitAttr = (char) i; break; case SET1_T_INACTIVEWINDOWCOLOR: EditVars.InactiveWindowColor = i; break; case SET1_T_TABAMOUNT: EditVars.TabAmount = i; break; case SET1_T_SHIFTWIDTH: EditVars.ShiftWidth = i; break; case SET1_T_PAGELINESEXPOSED: EditVars.PageLinesExposed = i; break; case SET1_T_HARDTAB: EditVars.HardTab = i; redisplay = TRUE; break; case SET1_T_STACKK: if( EditFlags.Starting ) { EditVars.StackK = i; } break; case SET1_T_LINENUMWINWIDTH: EditVars.LineNumWinWidth = i; break; case SET1_T_MAXWINDOWTILEX: EditVars.MaxWindowTileX = i; break; case SET1_T_MAXWINDOWTILEY: EditVars.MaxWindowTileY = i; break; case SET1_T_MAXSWAPK: SwapBlockInit( i ); break; case SET1_T_MAXEMSK: #ifndef NOEMS EMSBlockInit( i ); #endif break; case SET1_T_MAXXMSK: #ifndef NOXMS XMSBlockInit( i ); #endif break; case SET1_T_MAXFILTERHISTORY: FilterHistInit( i ); break; case SET1_T_MAXCLHISTORY: CLHistInit( i ); break; case SET1_T_MAXFINDHISTORY: FindHistInit( i ); break; case SET1_T_MAXLASTFILESHISTORY: LastFilesHistInit( i ); break; case SET1_T_MAXTILECOLORS: k = (EditVars.TileColors == NULL) ? 0 : EditVars.MaxTileColors + 1; EditVars.MaxTileColors = i; EditVars.TileColors = MemReAlloc( EditVars.TileColors, sizeof( type_style ) * ( EditVars.MaxTileColors + 1 ) ); for( ; k <= EditVars.MaxTileColors; ++k ) { EditVars.TileColors[k].foreground = -1; EditVars.TileColors[k].background = -1; EditVars.TileColors[k].font = -1; } break; case SET1_T_CLOCKX: EditVars.ClockX = i; GetClockStart(); break; case SET1_T_CLOCKY: EditVars.ClockY = i; GetClockStart(); break; case SET1_T_SPINX: EditVars.SpinX = i; GetSpinStart(); break; case SET1_T_SPINY: EditVars.SpinY = i; GetSpinStart(); break; case SET1_T_MAXLINELEN: /* file save fails if 1 line is > MAX_IO_BUFFER */ i = __min( i, MAX_IO_BUFFER ); EditVars.MaxLine = i; StaticStart(); WorkLine = MemReAlloc( WorkLine, sizeof( line ) + EditVars.MaxLine + 2 ); break; case SET1_T_TOOLBARBUTTONHEIGHT: EditVars.ToolBarButtonHeight = i; #ifdef __WIN__ ResizeRoot(); #endif break; case SET1_T_TOOLBARBUTTONWIDTH: EditVars.ToolBarButtonWidth = i; #ifdef __WIN__ ResizeRoot(); #endif break; case SET1_T_TOOLBARCOLOR: EditVars.ToolBarColor = i; #ifdef __WIN__ if( GetToolbarWindow() != NULL ) { InvalidateRect( GetToolbarWindow(), NULL, TRUE ); UpdateWindow( GetToolbarWindow() ); } #endif break; default: return( ERR_INVALID_SET_COMMAND ); } if( msgFlag ) { MySprintf( fn, "%s set to %d", GetTokenStringCVT( SetTokens1, j, settokstr, TRUE ), i ); } break; } } if( msgFlag && rc == ERR_NO_ERR && !EditFlags.Quiet ) { setMessage( fn, redisplay ); rc = DO_NOT_CLEAR_MESSAGE_WINDOW; } if( rc == ERR_NO_ERR && toggle ) { strcpy( value, save ); } return( rc ); #endif /* VICOMP */ } /* processSetToken */
void dump_item(NXWCLIENT ps, PKGx08 *pp) // Item is dropped on ground or a character { if (ps == NULL) return; tile_st tile; NXWSOCKET s=ps->toInt(); P_CHAR pc=ps->currChar(); VALIDATEPC(pc); P_ITEM pi=pointers::findItemBySerial(pp->Iserial); if (!ISVALIDPI(pi)) { LogError("client sent bad itemserial %d",pp->Iserial); return; } if ( isCharSerial(pi->getContSerial()) && pi->getContSerial() != pc->getSerial32() ) { P_CHAR pc_i = pointers::findCharBySerial(pi->getContSerial()); if (ISVALIDPC(pc_i)) pc_i->sysmsg("Warning, backpack disappearing bug located!"); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); } if (pi->magic == 2) { //Luxor -- not movable objects if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } pi->setContSerial( pi->getContSerial(true) ); pi->MoveTo( pi->getOldPosition() ); pi->layer = pi->oldlayer; pi->Refresh(); return; } if(pi!=NULL) { weights::NewCalc(pc); statwindow(pc,pc); } //Ripper...so order/chaos shields disappear when on ground. if( pi->getId()==0x1BC3 || pi->getId()==0x1BC4 ) { pc->playSFX( 0x01FE); staticeffect(DEREF_P_CHAR(pc), 0x37, 0x2A, 0x09, 0x06); pi->Delete(); return; } //test UOP blocking Tauriel 1-12-99 if (!pi->isInWorld()) { item_bounce6(ps,pi); return; } data::seekTile(pi->getId(), tile); if (!pc->IsGM() && ((pi->magic==2 || (tile.weight==255 && pi->magic!=1))&&!pc->canAllMove()) || ( (pi->magic==3 || pi->magic==4) && !(pi->getOwnerSerial32()==pc->getSerial32()))) { item_bounce6(ps,pi); return; } if (buffer[s][5]!=(unsigned char)'\xFF') { if (pi->amxevents[EVENT_IDROPINLAND]!=NULL) { g_bByPass = false; pi->MoveTo(pp->TxLoc,pp->TyLoc,pp->TzLoc); pi->amxevents[EVENT_IDROPINLAND]->Call( pi->getSerial32(), pc->getSerial32() ); if (g_bByPass) { pi->Refresh(); return; } } /* //<Luxor> g_bByPass = false; pi->runAmxEvent( EVENT_IDROPINLAND, pi->getSerial32(), pc->getSerial32() ); if (g_bByPass) { pi->Refresh(); return; } //</Luxor> */ NxwSocketWrapper sw; sw.fillOnline( pi ); for( sw.rewind(); !sw.isEmpty(); sw++ ) { SendDeleteObjectPkt( sw.getSocket(), pi->getSerial32() ); } pi->MoveTo(pp->TxLoc,pp->TyLoc,pp->TzLoc); pi->setContSerial(-1); P_ITEM p_boat = Boats->GetBoat(pi->getPosition()); if(ISVALIDPI(p_boat)) { pi->SetMultiSerial(p_boat->getSerial32()); } pi->Refresh(); } else { if ( !ItemDroppedOnChar(ps, pp, pi) ) { //<Luxor>: Line of sight check //This part avoids the circle of transparency walls bug //----- if ( !lineOfSight( pc->getPosition(), Loc( pp->TxLoc, pp->TyLoc, pp->TzLoc ) ) ) { ps->sysmsg(TRANSLATE("You cannot place an item there!")); 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> //<Luxor> Items count check if (!pc->IsGM()) { NxwItemWrapper si; si.fillItemsAtXY( pp->TxLoc, pp->TyLoc ); if (si.size() >= 2) { //Only 2 items permitted ps->sysmsg(TRANSLATE("There is not enough space there!")); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } if (ISVALIDPI(pc->getBackpack())) { pi->setCont(pc->getBackpack()); pi->SetRandPosInCont(pc->getBackpack()); } else { pi->setContSerial( pi->getContSerial(true) ); pi->setPosition( pi->getOldPosition() ); } pi->layer = pi->oldlayer; pi->Refresh(); return; } } //</Luxor> } weights::NewCalc(pc); // Ison 2-20-99 statwindow(pc,pc); pc->playSFX( itemsfx(pi->getId()) ); //Boats ! if (pc->getMultiSerial32() > 0) //How can they put an item in a multi if they aren't in one themselves Cut lag by not checking everytime something is put down { P_ITEM multi = pointers::findItemBySerial( pc->getMultiSerial32() ); if (ISVALIDPI(multi)) { //setserial(DEREF_P_ITEM(pi),DEREF_P_ITEM(multi),7); pi->SetMultiSerial(multi->getSerial32()); } } //End Boats } }
/* * MainWindowProc - procedure for main (root) window */ WINEXPORT LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { RECT rect; vi_rc rc; HANDLE hfileinfo; int cnt, i; char *buff; switch( msg ) { case WM_CREATE: Root = hwnd; GetClientRect( hwnd, &rect ); EditContainer = CreateContainerWindow( &rect ); InitWindows(); DragAcceptFiles( hwnd, TRUE ); timerID = SetTimer( hwnd, TIMER_ID, 60L * 1000L, NULL ); break; case WM_DROPFILES: hfileinfo = (HANDLE) wparam; cnt = DragQueryFile( hfileinfo, (UINT)-1, NULL, 0 ); buff = alloca( FILENAME_MAX + 2 ); /* we add a " at the beginning and at the end so we can handle path- and filenames with spaces */ if( buff != NULL ) { buff[0] = '"'; /* one " at the beginning of the filename */ for( i = 0; i < cnt; i++ ) { if( DragQueryFile( hfileinfo, i, buff + 1, FILENAME_MAX ) == (UINT)-1 ) { break; } strcat( buff, "\"" ); rc = EditFile( buff, FALSE ); if( rc > ERR_NO_ERR ) { Error( GetErrorMsg( rc ) ); } } } DragFinish( hfileinfo ); break; case WM_TIMER: UpdateStatusWindow(); break; case WM_KEYDOWN: if( WindowsKeyPush( wparam, HIWORD( lparam ) ) ) { return( 0 ); } break; case WM_SIZE: DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ); RootState = wparam; if( wparam != SIZE_MINIMIZED ) { ResizeRoot(); GetWindowRect( hwnd, &RootRect ); if( wparam != SIZE_MAXIMIZED ) { RootState = 0; } } return( 0 ); case WM_MOVE: DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ); if( RootState != SIZE_MINIMIZED ) { GetWindowRect( hwnd, &RootRect ); } return( 0 ); case WM_ACTIVATEAPP: if( BAD_ID( CurrentWindow ) ) { break; } SetFocus( Root ); #if 0 if( !wparam ) { InactiveWindow( CurrentWindow ); } else { SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L ); } #endif if( wparam ) { ResetEditWindowCursor( CurrentWindow ); } else { GoodbyeCursor( CurrentWindow ); } break; case WM_MOUSEACTIVATE: SetFocus( hwnd ); return( MA_ACTIVATE ); case WM_SETFOCUS: if( BAD_ID( CurrentWindow ) ) { break; } if( !IsIconic( CurrentWindow ) ) { SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L ); DCUpdate(); SetWindowCursor(); SetWindowCursorForReal(); return( 0 ); } break; case WM_NCLBUTTONDBLCLK: break; case WM_COMMAND: if( LOWORD( wparam ) > 0xF000 ) { break; } else { rc = MenuCommand( LOWORD( wparam ) ); if( rc != MENU_COMMAND_NOT_HANDLED ) { DCUpdateAll(); if( rc > ERR_NO_ERR ) { char *msg; msg = GetErrorMsg( rc ); Error( msg ); } } SetWindowCursor(); } return( 0 ); case WM_INITMENU: if( (HMENU)wparam == GetMenu( hwnd ) ) { HandleInitMenu( (HMENU)wparam ); } else { ResetMenuBits(); } break; case WM_MENUSELECT: HandleMenuSelect( wparam, lparam ); break; case WM_ENDSESSION: if( wparam ) { ExitEditor( 0 ); // will not return } return( 0 ); case WM_QUERYENDSESSION: return( ExitWithPrompt( FALSE, TRUE ) ); case WM_CLOSE: ExitWithPrompt( TRUE, TRUE ); return( 0 ); #ifdef __NT__ case WM_MOUSEWHEEL: { int i, increment; ULONG linesPerNotch; HWND activeWnd; activeWnd = (HWND)SendMessage( EditContainer, WM_MDIGETACTIVE, 0, 0 ); SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &linesPerNotch, 0 ); increment = GET_WHEEL_DELTA_WPARAM( wparam ) / 120; // see WM_MOUSEWHEEL-documentation for information about the "120" if( increment > 0 ) { for( i = 0; i < increment * (int)linesPerNotch; i++ ) { SendMessage( activeWnd, WM_VSCROLL, SB_LINEUP, 0 ); } } else { for( i = 0; i < (-increment) * (int)linesPerNotch; i++ ) { SendMessage( activeWnd, WM_VSCROLL, SB_LINEDOWN, 0 ); } } } return( 0 ); #endif case WM_DESTROY: DestroyToolBar(); DragAcceptFiles( hwnd, FALSE ); EditContainer = 0; if( timerID ) { KillTimer( hwnd, TIMER_ID ); } return( 0 ); } return( DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ) ); } /* MainWindowProc */
LONG NotifyHandle(HIMC hUICurIMC, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LONG lRet = 0L; LPINPUTCONTEXT lpIMC; HGLOBAL hUIExtra; LPUIEXTRA lpUIExtra; if (!(lpIMC = ImmLockIMC(hUICurIMC))) return 0L; hUIExtra = (HGLOBAL)GetWindowLong(hWnd,IMMGWL_PRIVATE); lpUIExtra = (LPUIEXTRA)GlobalLock(hUIExtra); switch (wParam) { case IMN_CLOSESTATUSWINDOW: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_CLOSESTATUSWINDOW\n")); if (IsWindow(lpUIExtra->uiStatus.hWnd)) { ShowWindow(lpUIExtra->uiStatus.hWnd,SW_HIDE); } break; case IMN_OPENSTATUSWINDOW: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_OPENSTATUSWINDOW\n")); CreateStatusWindow( hWnd, lpUIExtra); break; case IMN_OPENCANDIDATE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_OPENCANDIDATE\n")); break; case IMN_CHANGECANDIDATE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_CHANGECANDIDATE\n")); break; case IMN_CLOSECANDIDATE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_CLOSECANDIDATE\n")); break; case IMN_SETCONVERSIONMODE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETCONVERSIONMODE\n")); UpdateStatusWindow(lpUIExtra); break; case IMN_SETSENTENCEMODE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETSENTENCEMODE\n")); break; case IMN_SETOPENSTATUS: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETOPENSTATUS\n")); if(!IsIMEOpen(hUICurIMC)) { MakeResultString(hUICurIMC,FALSE); } UpdateStatusWindow(lpUIExtra); break; case IMN_SETCANDIDATEPOS: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETCANDIDATEPOS\n")); break; case IMN_SETCOMPOSITIONFONT: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETCOMPOSITIONFONT\n")); break; case IMN_SETCOMPOSITIONWINDOW: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETCOMPOSITIONWINDOW\n")); if(wConversionSet & CONVERSION_SET_FOLLOW) { POINT ptSrc; SIZE szOffset; HDC hDC; HFONT oldFont; ptSrc = lpIMC->cfCompForm.ptCurrentPos; ClientToScreen(lpIMC->hWnd, &ptSrc); hDC = GetDC(lpIMC->hWnd); oldFont = SelectObject(hDC, hUIFont); GetTextExtentPoint(hDC,"A",1,&szOffset); SelectObject(hDC, oldFont); ReleaseDC(lpIMC->hWnd,hDC); lpUIExtra->uiComp.pt.x = ptSrc.x + szOffset.cx; lpUIExtra->uiComp.pt.y = ptSrc.y + szOffset.cy; } if (IsWindow(lpUIExtra->uiComp.hWnd)) InvalidateRect(lpUIExtra->uiComp.hWnd,NULL,FALSE); break; case IMN_GUIDELINE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_GUIDELINE\n")); break; case IMN_SETSTATUSWINDOWPOS: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_SETSTATUSWINDOWPOS\n")); break; case IMN_PRIVATE: DebugLog(1,(DebugLogFile,"UIWnd:WM_IME_NOTIFY:IMN_PRIVATE\n")); break; default: break; } GlobalUnlock(hUIExtra); ImmUnlockIMC(hUICurIMC); return lRet; }
void cDragdrop::wear_item(P_CLIENT ps) // Item is dropped on paperdoll { int j, k; tile_st tile; int serial, serhash, ci, letsbounce=0; // AntiChrist (5) - new ITEMHAND system UOXSOCKET s=ps->GetSocket(); int cc=ps->GetCurrChar(); P_CHAR pc_currchar = MAKE_CHARREF_LR(cc); int cserial=calcserial(buffer[s][6],buffer[s][7],buffer[s][8],buffer[s][9]); if(cserial==-1) return; k=calcCharFromSer( cserial ); if( chars[k].dead ) //Exploit fix: Dead ppl can't equip anything. return; P_ITEM pi=FindItemBySerPtr(buffer[s]+1); if (!pi) return; pi->flags.isBeeingDragged=false; // if (clientDimension[s]==3) // { Map->SeekTile(pi->id(), &tile); // sprintf(temp, "Tiledata: name: %s flag1: %i flag2: %i flag3: %i flag4: %i layer: %i\n", tile.name, tile.flag1, tile.flag2, tile.flag3, tile.flag4, tile.layer); // clConsole.send(temp); if (tile.layer==0) { sysmessage(s,"You can't wear that"); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } // } if (pi->id1>=0x40) return; // LB, client crashfix if multi-objects are moved to PD if (k==DEREF_P_CHAR(pc_currchar) || pc_currchar->isGM()) { if (k!=-1) //lb if (k==DEREF_P_CHAR(pc_currchar) && pi->st>chars[k].st) { sysmessage(s,"You are not strong enough to use that."); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } if (pc_currchar->id1==0x01 && pc_currchar->id2==0x90) // Ripper...so males cant wear female armor if (pi->id1==0x1c && ( pi->id2==0x00 || pi->id2==0x02 || pi->id2==0x04 || pi->id2==0x06 || pi->id2==0x08 || pi->id2==0x0a || pi->id2==0x0c)) { sysmessage(s,"You cant wear female armor!"); Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); } return; } // if (clientDimension[s]==2) Map->SeekTile(pi->id(), &tile); if ((((pi->magic==2)||((tile.weight==255)&&(pi->magic!=1)))&&((pc_currchar->priv2&1)==0)) || ( (pi->magic==3|| pi->magic==4) && !pc_currchar->Owns(pi))) { item_bounce6(ps,pi); return; } // - AntiChrist (4) - checks for new ITEMHAND system // - now you can't equip 2 hnd weapons with 1hnd weapons nor shields!! serial=pc_currchar->serial; vector<SERIAL> vecContainer = contsp.getData(serial); for (ci=0;ci<vecContainer.size();ci++) { P_ITEM pi2 = FindItemBySerial(vecContainer[ci]); if (pi2 != NULL && pi2->contserial == serial) { if (pi2->itmhand==1 && pi->itmhand==1) { sysmessage(s,"You already have a weapon equipped!"); letsbounce=1; } else if (pi2->itmhand==2 && pi->itmhand==1) { sysmessage(s,"Your hands are both occupied!"); letsbounce=1; } else if (pi2->itmhand==1 && pi->itmhand==2) { sysmessage(s,"You cannot equip a two handed weapon with a weapon equipped!"); letsbounce=1; } else if (pi2->itmhand==2 && pi->itmhand==2) { sysmessage(s,"You cannot equip a two handed weapon with a two handed weapon equipped!"); letsbounce=1; } else if (pi2->itmhand==2 && pi->itmhand==3) { sysmessage(s,"You cannot equip a shield with a two handed weapon equipped!"); letsbounce=1; } else if (pi2->itmhand==3 && pi->itmhand==2) { sysmessage(s,"You cannot equip a two handed weapon with a shield equipped!"); letsbounce=1; } else if (pi2->layer == tile.layer) { sysmessage(s, "You already have an armor equipped!"); letsbounce = 1; } } if(letsbounce)//Let's bounce the item { Sndbounce5(s); if (ps->IsDragging()) { ps->ResetDragging(); item_bounce4(s,pi); UpdateStatusWindow(s,pi); itemsfx(s, pi->id()); // antichrist } return; } } if (!(pc_currchar->isGM())) //Ripper..players cant equip items on other players or npc`s paperdolls. { if ((k != DEREF_P_CHAR(pc_currchar)) && (!chars[k].isNpc())) { sysmessage(s, "You cant put items on other players!"); item_bounce6(ps,pi); return; } } pi->SetContSerial(LongFromCharPtr(buffer[s]+6)); pi->layer=buffer[s][5]; // AntiChrist - now the STAT BONUS works - pc_currchar->st = (pc_currchar->st + pi->st2); pc_currchar->chgDex(pi->dx2); pc_currchar->in = (pc_currchar->in + pi->in2); if (pi->trigtype==2) // -Frazurbluu- Trigger Type 2 is my new trigger type *- { Trig->triggerwitem(s, pi, 1); // trigger is fired } // AntiChrist -- for poisoned items if (showlayer) clConsole.send("Item equipped on layer %i.\n",pi->layer); SndRemoveitem(pi->serial); LongToCharPtr(pi->serial,wearitem+1); ShortToCharPtr(pi->id(),wearitem+5); wearitem[8]=pi->layer; LongToCharPtr(pi->contserial,wearitem+9); wearitem[13]=pi->color1; wearitem[14]=pi->color2; Xsend(s, wearitem, 15); wornitems(s, k);//send update to current socket // -Frazurbluu- Worn item triggers will need code here // Trigger cod ewill also need the adjustments made for skill adding // An apply/unapply type of variable must be added for skill gains // Spell Item will have to be considered, like a necklace of reflection for (j=0;j<now;j++) { if (perm[j] && inrange1p(k, currchar[j]) && (j!=s))//and to all inrange sockets (without re-sending to current socket)//AntiChrist wornitems(j, k); } itemsfx(s, pi->id()); // Dupois - see itemsfx() for details // Added Oct 09, 1998 Weight->NewCalc(DEREF_P_CHAR(pc_currchar)); // Ison 2-20-99 statwindow(s,DEREF_P_CHAR(pc_currchar)); if (pi->glow>0) { pc_currchar->removeHalo(pi); // if gm equips on differnt player it needs to be deleted out of the hashteble chars[k].addHalo(pi); chars[k].glowHalo(pi); } } }
/* * doInitializeEditor - do just that */ static void doInitializeEditor( int argc, char *argv[] ) { int i, arg, cnt, ocnt, startcnt = 0; srcline sline; int k, j; char tmp[FILENAME_MAX], c[1]; char buff[MAX_STR], file[MAX_STR], **list; char cmd[MAX_STR * 2]; char *parm; char *startup[MAX_STARTUP]; char *startup_parms[MAX_STARTUP]; vi_rc rc; vi_rc rc1; /* * Make sure WATCOM is setup and if it is not, make a best guess. */ watcom_setup_env(); /* * If EDPATH is not set, use system default %WATCOM%\EDDAT. */ if( getenv( "EDPATH" ) == NULL ) { char *watcom; watcom = getenv( "WATCOM" ); if( watcom != NULL ) { char edpath[FILENAME_MAX]; sprintf( edpath, "%s%c%s", watcom, FILE_SEP, "eddat" ); if( setenv( "EDPATH", edpath, 0 ) != 0 ) { /* * Bail out silently on error, as we will get error message later on. */ } } } /* * misc. set up */ MaxMemFree = MemSize(); StaticStart(); FTSInit(); BoundDataInit(); EditFlags.Starting = true; InitCommandLine(); ChkExtendedKbd(); SSInitBeforeConfig(); GetCWD1( &HomeDirectory ); GetCWD1( &CurrentDirectory ); SetCWD( HomeDirectory ); if( cfgFN == NULL ){ cfgFN = DupString( CFG_NAME ); } checkFlags( &argc, argv, startup, startup_parms, &startcnt ); ScreenInit(); SetWindowSizes(); EditFlags.ClockActive = false; SetInterrupts(); #ifdef __WIN__ InitClrPick(); InitFtPick(); SubclassGenericInit(); CursorOp( COP_INIT ); #else InitColors(); #endif InitSavebufs(); InitKeyMaps(); /* * initial configuration */ EditVars.Majick = MemStrDup( "()~@" ); EditVars.FileEndString = MemStrDup( "[END_OF_FILE]" ); MatchInit(); SetGadgetString( NULL ); WorkLine = MemAlloc( sizeof( line ) + EditVars.MaxLine + 2 ); WorkLine->len = -1; sline = 0; if( cfgFN[0] != 0 ) { c[0] = 0; rc = Source( cfgFN, c, &sline ); if( rc == ERR_FILE_NOT_FOUND ) { #ifdef __WIN__ CloseStartupDialog(); MessageBox( (HWND)NULLHANDLE, "Could not locate configuration information; please make sure your EDPATH environment variable is set correctly", EditorName, MB_OK ); ExitEditor( -1 ); #else rc = ERR_NO_ERR; #endif } } else { rc = ERR_NO_ERR; } if( wantNoReadEntireFile ) { EditFlags.ReadEntireFile = false; } VerifyTmpDir(); while( LostFileCheck() ); HookScriptCheck(); if( EditFlags.Quiet ) { EditFlags.Spinning = false; EditFlags.Clock = false; } ExtendedMemoryInit(); /* * more misc. setup */ if( EditVars.WordDefn == NULL ) { EditVars.WordDefn = DupString( &WordDefnDefault[6] ); InitWordSearch( EditVars.WordDefn ); } if( EditVars.WordAltDefn == NULL ) { EditVars.WordAltDefn = DupString( WordDefnDefault ); } if( EditVars.TagFileName == NULL ) { EditVars.TagFileName = DupString( "tags" ); } DotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); AltDotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); DotCmd = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); SwapBlockInit( EditVars.MaxSwapBlocks ); ReadBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); WriteBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); FindHistInit( EditVars.FindHist.max ); FilterHistInit( EditVars.FilterHist.max ); CLHistInit( EditVars.CLHist.max ); LastFilesHistInit( EditVars.LastFilesHist.max ); GetClockStart(); GetSpinStart(); SelRgnInit(); SSInitAfterConfig(); #if defined( VI_RCS ) ViRCSInit(); #endif /* * create windows */ StartWindows(); InitMouse(); rc1 = NewMessageWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } DoVersion(); rc1 = InitMenu(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.SpinningOurWheels = true; EditFlags.ClockActive = true; EditFlags.DisplayHold = true; rc1 = NewStatusWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.DisplayHold = false; MaxMemFreeAfterInit = MemSize(); /* * look for a tag: if there is one, set it up as the file to start */ EditFlags.WatchForBreak = true; if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif rc1 = LocateTag( cTag, file, buff ); cFN = file; if( rc1 != ERR_NO_ERR ) { if( rc1 == ERR_TAG_NOT_FOUND ) { Error( GetErrorMsg( rc1 ), cTag ); ExitEditor( 0 ); } FatalError( rc1 ); } } /* * start specified file(s) */ cmd[0] = 'e'; cmd[1] = 0; arg = argc - 1; k = 1; while( !EditFlags.NoInitialFileLoad ) { if( cFN == nullFN && !EditFlags.UseNoName ) { break; } #ifdef __NT__ { int k2; int arg2; char path[_MAX_PATH]; int found; int fd; size_t len; size_t len1; char *p; /* * check for the existence of a file name containing spaces, and open it if * there is one */ len = _MAX_PATH - 1; found = 0; p = path; arg2 = arg; for( k2 = k; argv[k2] != NULL; ) { len1 = strlen( argv[k2] ); if( len1 > len ) break; memcpy( p, argv[k2], len1 ); p += len1; *p = '\0'; len -= len1; --arg2; ++k2; fd = open( path, O_RDONLY ); if( fd != -1 ) { close( fd ); k = k2; arg = arg2; found = 1; break; } *p++ = ' '; } if( found ) { #ifndef __UNIX__ len1 = strlen( path ); if( path[len1 - 1] == '.' ) path[len1 - 1] = '\0'; #endif rc1 = NewFile( path, false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } cFN = argv[k]; if( arg < 1 ) { break; } continue; } } #endif strcat( cmd, SingleBlank ); strcat( cmd, cFN ); ocnt = cnt = ExpandFileNames( cFN, &list ); if( cnt == 0 ) { cnt = 1; } else { cFN = list[0]; } for( j = 0; j < cnt; j++ ) { rc1 = NewFile( cFN, false ); if( rc1 != ERR_NO_ERR && rc1 != NEW_FILE ) { FatalError( rc1 ); } if( EditFlags.BreakPressed ) { break; } if( cnt > 0 && j < cnt - 1 ) { cFN = list[j + 1]; } } if( ocnt > 0 ) { MemFreeList( ocnt, list ); } if( EditFlags.BreakPressed ) { ClearBreak(); break; } k++; arg--; if( cTag != NULL || arg < 1 ) { break; } cFN = argv[k]; } if( EditFlags.StdIOMode ) { rc1 = NewFile( "stdio", false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } } EditFlags.WatchForBreak = false; EditFlags.Starting = false; /* * if there was a tag, do the appropriate search */ if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { if( buff[0] != '/' ) { i = atoi( buff ); rc1 = GoToLineNoRelCurs( i ); } else { rc1 = FindTag( buff ); } if( rc1 > 0 ) { Error( GetErrorMsg( rc1 ) ); } } /* * try to run startup file */ if( EditFlags.RecoverLostFiles ) { startcnt = 0; } for( i = 0; i < startcnt; i++ ) { GetFromEnv( startup[i], tmp ); ReplaceString( &cfgFN, tmp ); if( cfgFN[0] != 0 ) { if( startup_parms[i] != NULL ) { parm = startup_parms[i]; } else { c[0] = 0; parm = c; } #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif sline = 0; rc = Source( cfgFN, parm, &sline ); } } if( rc > ERR_NO_ERR ) { Error( "%s on line %u of \"%s\"", GetErrorMsg( rc ), sline, cfgFN ); } if( argc == 1 ) { LoadHistory( NULL ); } else { LoadHistory( cmd ); } if( EditVars.GrepDefault == NULL ) { EditVars.GrepDefault = DupString( "*.(c|h)" ); } if( goCmd[0] != 0 ) { KeyAddString( goCmd ); } if( keysToPush != NULL ) { KeyAddString( keysToPush ); } #ifdef __WIN__ if( lineToGoTo != 0 ) { SetCurrentLine( lineToGoTo ); NewCursor( CurrentWindow, EditVars.NormalCursorType ); } #endif AutoSaveInit(); HalfPageLines = WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES ) / 2 - 1; #if defined( _M_X64 ) VarAddGlobalStr( "OSX64", "1" ); #elif defined( _M_IX86 ) && !defined( _M_I86 ) VarAddGlobalStr( "OS386", "1" ); #endif if( EditVars.StatusString == NULL ) { EditVars.StatusString = DupString( "L:$6L$nC:$6C" ); } UpdateStatusWindow(); #ifdef __WIN__ if( CurrentInfo == NULL ) { // no file loaded - screen is disconcertenly empty - reassure DisplayFileStatus(); } #endif NewCursor( CurrentWindow, EditVars.NormalCursorType ); #if defined( __NT__ ) && !defined( __WIN__ ) { SetConsoleActiveScreenBuffer( OutputHandle ); } #endif } /* doInitializeEditor */
static bool ItemDroppedOnChar(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi) { if (ps == NULL) return true; VALIDATEPIR(pi, false); NXWSOCKET s = ps->toInt(); // CHARACTER cc=ps->currCharIdx(); P_CHAR pTC = pointers::findCharBySerial(pp->Tserial); // the targeted character VALIDATEPCR(pTC, false); P_CHAR pc_currchar = ps->currChar(); //MAKE_CHAR_REF(cc); VALIDATEPCR(pc_currchar, false); Location charpos = pc_currchar->getPosition(); if (!pTC) return true; if (pi->amxevents[EVENT_IDROPONCHAR]!=NULL) { g_bByPass = false; pi->amxevents[EVENT_IDROPONCHAR]->Call( pi->getSerial32(), pc_currchar->getSerial32(), pTC->getSerial32() ); if (g_bByPass) { pi->Refresh(); return true; } } if (pc_currchar->getSerial32() != pTC->getSerial32() /*DEREF_P_CHAR(pTC)!=cc*/) { if (pTC->npc) { if(!pTC->HasHumanBody()) { ItemDroppedOnPet( ps, pp, pi); } else // Item dropped on a Human character { // Item dropped on a Guard (possible bounty quest) if( ( pTC->npc == 1 ) && ( pTC->npcaitype == NPCAI_TELEPORTGUARD ) ) { ItemDroppedOnGuard( ps, pp, pi); } if ( pTC->npcaitype == NPCAI_BEGGAR ) { ItemDroppedOnBeggar( ps, pp, pi); } //This crazy training stuff done by Anthracks ([email protected]) if(pc_currchar->isBeingTrained() ) { if ( pc_currchar->trainer != pTC->getSerial32()) { pTC->talk(s, TRANSLATE("Thank thee kindly, but I have done nothing to warrant a gift."),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } return true; } else // The player is training from this NPC { ItemDroppedOnTrainer( ps, pp, pi); } } if ( pTC->isHirable() ) { // test if gold is enough if ( pi->amount < pTC->getHireFee() ) { pTC->talk(s, TRANSLATE("I need much more gold if i shall be working for you !"),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } return true; } else if ( pi->amount >= pTC->getHireFee() ) { if ( pi->amount > pTC->getHireFee() ) { pi->amount=(UI16)(pi->amount - pTC->getHireFee()); pTC->talk(s, TRANSLATE("Thank thee kindly, but this is more than i need for the day."),0); Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); item_bounce5(s,pi); } } pTC->setOwner(pc_currchar); tempfx::add(pTC, pc_currchar, tempfx::NPC_HIRECOST, 0, 0, 0, 0, (UI16)(MY_CLOCKS_PER_SEC*secondsperuominute*60*24 )); // call callback every uo day return true; } } }//if human or not } else // dropped on another player { // By Polygon: Avoid starting the trade if GM drops item on logged on char (crash fix) if ((pc_currchar->IsGM()) && !pTC->IsOnline()) { // Drop the item in the players pack instead // Get the pack P_ITEM pack = pTC->getBackpack(); if (pack != NULL) // Valid pack? { pack->AddItem(pi); // Add it weights::NewCalc(pTC); } else // No pack, give it back to the GM { pack = pc_currchar->getBackpack(); if (pack != NULL) // Valid pack? { pack->AddItem(pi); // Add it weights::NewCalc(pc_currchar); } else // Even GM has no pack? { // Drop it to it's feet pi->MoveTo( charpos ); pi->Refresh(); } } } else { //<Luxor>: secure trade P_ITEM tradeCont = tradestart(pc_currchar, pTC); if (ISVALIDPI(tradeCont)) { tradeCont->AddItem( pi, 30, 30 ); } else { Sndbounce5(s); if (ps->isDragging()) { ps->resetDragging(); UpdateStatusWindow(s,pi); } } //</Luxor> } } } else // dumping stuff to his own backpack ! { ItemDroppedOnSelf( ps, pp, pi); } return true; }