Page 1 of 1

Little Cancel Patch

Posted: 20 Feb 2005, 00:00
by Mra
Didn't really know in which Subforum to post, so I'll just post patch(es) here until somebody convinces me not to do that ;)

Found your great client today... Finally somebody completed the task of doing a real client based on one of the RO-protocol-servers, even if you're going to change the protocol/server soon.
Anyways, just saw http://www.lindeijer.nl/flyspray/?do=details&id=7

I never used eathena, just got my old yare/nezumi cvs/work dumps/packetlist, so it would be great if you could release your cvs for the server to the public (If you're not using eathena without any code changes, then I'll just get newest eathena version)...

But anyways, this will reimplement the Cancel Button and make it reenable walking around (Sorry, no .diff)

File: /src/gui/npc.c

Code: Select all

NpcListDialog::NpcListDialog():
    Window("NPC")
{
    itemList = new ListBox(this);
    scrollArea = new ScrollArea(itemList);
    okButton = new Button("OK");
    cancelButton = new Button("Cancel");

    setSize(260, 175);
    scrollArea->setDimension(gcn::Rectangle(
                5, 5, 250, 160 - okButton->getHeight()));
    okButton->setPosition(
            260 - 5 - okButton->getWidth(),
            175 - 5 - okButton->getHeight());
    cancelButton->setPosition(
            260 - 5 - okButton->getWidth() - 5 - cancelButton->getWidth(),
            175 - 5 - cancelButton->getHeight());

    itemList->setEventId("item");
    okButton->setEventId("ok");
    cancelButton->setEventId("cancel");

    itemList->addActionListener(this);
    okButton->addActionListener(this);
    cancelButton->addActionListener(this);

    add(scrollArea);
    add(okButton);
    add(cancelButton);

    setLocationRelativeTo(getParent());
}

Code: Select all

NpcListDialog::~NpcListDialog()
{
    delete okButton;
    delete cancelButton;
    delete itemList;
    delete scrollArea;
}

Code: Select all

void NpcListDialog::action(const std::string& eventId)
{
    if (eventId == "ok") {
        // Send the selected index back to the server
        int selectedIndex = itemList->getSelected();
        if (selectedIndex > -1) {
            WFIFOW(0) = net_w_value(0x00b8);
            WFIFOL(2) = net_l_value(current_npc);
            WFIFOB(6) = net_b_value(selectedIndex + 1);
            WFIFOSET(7);
            setVisible(false);
            reset();
        }
    }
    else if (eventId == "cancel") {
        // 0xff packet means cancel
        WFIFOW(0) = net_w_value(0x00b8);
        WFIFOL(2) = net_l_value(current_npc);
        WFIFOB(6) = net_b_value(0xff);
        WFIFOSET(7);
        setVisible(false);
        reset();
    }
    
}
The original version is $Id: npc.cpp,v 1.13 2005/01/08 01:33:53 bjorn Exp $

And something slightly different: A question regarding your desired npc system:
Currently walking while talking to a npc is either enabled (= other players see you walk) (this happens, if the textbox you read happens to be the last one before close (ok = close)) or disabled (You can walk, but others don't see it)
This is (as far as i can guess without direct yare-eathena-client-comparison) a server-side problem....So another reason to give us the server cvs :P
Anyways, the question: How do you want the walking-while-talking to be?
Do you actually want the players to be able to walk while talking to a npc?
Or do you want them not to be able to walk? On local client & on others clients..
Or do you want the player to be able to walk, but only in a special range around the npc (for example 10 tiles) and if he leaves, the npc window either just disappears or he's stopped at the outer ring of this range....

Just asking because I'm pretty bored these days (yay school) and would like to help you getting forward if you don't mind ;)

Have a nice day
Mra

Posted: 20 Feb 2005, 01:16
by Bjørn

Code: Select all

        // 0xff packet means cancel
        WFIFOW(0) = net_w_value(0x00b8);
        WFIFOL(2) = net_l_value(current_npc);
        WFIFOB(6) = net_b_value(0xff);
        WFIFOSET(7); 
That's actually the part we were stuck on. Thanks for this, we'll be sure to integrate it. :)

As for the eAthena server, only a few people of the team know anything about that (I'd say 2, maybe 3). Nobody is very interested in eAthena or fixing problems that remain by using it (like this one), because we're at the moment writing down the plans for our own server.

Posted: 20 Feb 2005, 03:19
by Bjørn
I've committed it to CVS after checking that it works. Thanks a lot!

Posted: 20 Feb 2005, 09:12
by ElvenProgrammer
http://anime-com.info/themanaworld/athe ... server.zip

Here you can find the latest source code of our own server. It has only a small change to load our own map format. And this version is missing some NPC scripts I think, but should work anyway.

About the walking-while-talking thinghy I think it's better to use the RO way, I don't remember it at the moment. We will think on a something different probably when we will switch to our own server.

If you feel bored feel free to contact me or Hammerbear (Bjorn) to join the development team.

Tank you for the help :D

Posted: 20 Feb 2005, 12:11
by ElvenProgrammer
I was wondering if you have a good version of the protocol...maybe you can give it to me?

Posted: 20 Feb 2005, 15:50
by Mra
Nice to see you commited it ;)
Anyways, I know you're going to use your own server and I really look forward to that...

Joining the Development Team: I'm not a professional programmer and guess I don't meet your requirements :P

Thanks for the tmw-server package...

Packetlist: I was just using the last packet_table_en.txt from yare/nezumi/freya cvs before we broke up+latest yare/freya version...
I just went through the tmw-server files, there's exactly this very old file in the /doc directory, so I guess I won't need to give you that one...
Last yare/freya files include relatively much protocol information in the parse functions, but I guess you won't need that because you already have eathenas parse functions (haven't looked at that so far)

In yare soure it's like:
// for script NPC
case 0xb8: // NPC select menu
npc_menu_select(fd, RFIFOL(fd, 2), RFIFOB(fd, 6));
break;

--------------

int npc_menu_select(int fd, int npc_id, int sel) {
struct map_session_data *sd;
sd = session[fd]->session_data;

sd->local_reg[15] = sel;
if (sel == 0xff) {
sd->npc_pc = 0;
sd->npc_id = 0;
sd->npc_n = 0;
sd->status.talking_to_npc = 0;
return 0;
}
run_script(fd, sd);
return 0;
}

Anyways, I don't know if the yare/freya project is still alive and how far eathena has envolved, but if you want the latest yare/freya cvs code I got as a protocol reference, just post it...or don't, if you do not need it, I don't care ;)

Posted: 20 Feb 2005, 17:39
by maci
Joining the Development Team: I'm not a professional programmer and guess I don't meet your requirements
well i think we need every help we can get :D

Posted: 20 Feb 2005, 18:09
by ElvenProgrammer
The only requirement is to be willing to help :wink:

Posted: 22 Feb 2005, 00:53
by Mra
Well I would, if Elven would respond to my pm ;)

Posted: 22 Feb 2005, 20:00
by Bjørn
Mra wrote:Well I would, if Elven would respond to my pm ;)
Mind you he's at university and will return Friday. I'm not sure how often or if he checks the forums from university.

Posted: 22 Feb 2005, 22:53
by maci
you should come to our IRC channel

Posted: 23 Feb 2005, 17:16
by Mra
Elven's away...no problem ;)
IRC...I'm there already...

Ah, and here's another one, this will only allow you to walk or fight if you're not actually talking to a npc....Also a player won't be allowed to display multiple npc talks in one npc window by clicking multiple times at one / two npc(s) (therefore nomore switching the npcs before you're actually done talking to one)
I also moved the actionListener of BuySellDialog from graphic.cpp to the buysell.cpp, because all other listeners (except one) are also in their corresponding files...I wonder why you wrote it in graphic.php anyways...

I would appreciate it if you would commit my changes, feel free to ask me about them/change them/do not even read/use/commit them at all :p

Code: Select all

>> Running "cvs -z4 diff -u " (in "C:\Dev-Cpp\tmw")
Index: src/game.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/game.cpp,v
retrieving revision 1.141
diff -u -r1.141 game.cpp
--- src/game.cpp	20 Feb 2005 22:57:10 -0000	1.141
+++ src/game.cpp	23 Feb 2005 17:02:16 -0000
@@ -45,9 +45,9 @@
 unsigned char keyb_state;
 volatile int tick_time;
 volatile bool action_time = false;
-int current_npc, server_tick;
+int server_tick;
 extern unsigned char screen_mode;
-int fps = 0, frame = 0;
+int fps = 0, frame = 0, current_npc = 0;
 bool displayPathToMouse = false;
 
 OkDialog *deathNotice = NULL;
@@ -288,10 +288,15 @@
                 int id = find_npc(npc_x, npc_y);
                 if (id != 0)
                 {
-                    WFIFOW(0) = net_w_value(0x0090);
-                    WFIFOL(2) = net_l_value(id);
-                    WFIFOB(6) = 0;
-                    WFIFOSET(7);
+                    // Check if no conflicting npc window is open
+                    if (current_npc == 0)
+                    {
+                        WFIFOW(0) = net_w_value(0x0090);
+                        WFIFOL(2) = net_l_value(id);
+                        WFIFOB(6) = 0;
+                        WFIFOSET(7);
+                        current_npc = id;
+                    }
                 }
 
             }
@@ -309,7 +314,8 @@
     Uint8* keys;
     keys = SDL_GetKeyState(NULL);
 
-    if (walk_status == 0 && player_node->action != DEAD)
+    if (walk_status == 0 && player_node->action != DEAD
+        && current_npc == 0)
     {
         int x = player_node->x;
         int y = player_node->y;
@@ -600,6 +606,7 @@
                     npcTextDialog->addText(RFIFOP(8));
                     npcListDialog->setVisible(false);
                     npcTextDialog->setVisible(true);
+                    current_npc = RFIFOL(4);
                     break;
                     // Get the items
                 case 0x01ee:
@@ -658,6 +665,7 @@
                         add_node(temp);
                         player_node = temp;
                         player_node->action = STAND;
+                        current_npc = 0;
                         player_node->frame = 0;
                         player_node->x = RFIFOW(18);
                         player_node->y = RFIFOW(20);
@@ -897,7 +905,7 @@
                     // Answer to buy
                 case 0x00ca:
                     if (RFIFOB(2) == 0)
-                        chatBox->chat_log("Thanks for buying", BY_SERVER);
+                        chatBox->chat_log("Thanks for buying", BY_SERVER);   
                     else
                         chatBox->chat_log("Unable to buy", BY_SERVER);
                     break;
@@ -973,7 +981,6 @@
                     // Close button in NPC dialog
                 case 0x00b6:
                     strcpy(npc_button, "Close");
-                    current_npc = RFIFOL(2);
                     break;
                     // List in NPC dialog
                 case 0x00b7:
cvs diff: Diffing src/graphic
Index: src/graphic/graphic.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/graphic/graphic.cpp,v
retrieving revision 1.125
diff -u -r1.125 graphic.cpp
--- src/graphic/graphic.cpp	20 Feb 2005 22:57:11 -0000	1.125
+++ src/graphic/graphic.cpp	23 Feb 2005 17:02:16 -0000
@@ -75,28 +75,6 @@
     }
 }
 
-void BuySellListener::action(const std::string& eventId)
-{
-    int actionId = -1;
-
-    if (eventId == "buy") {
-        actionId = 0;
-    }
-    else if (eventId == "sell") {
-        actionId = 1;
-    }
-
-    if (actionId > -1) {
-        WFIFOW(0) = net_w_value(0x00c5);
-        WFIFOL(2) = net_l_value(current_npc);
-        WFIFOB(6) = net_b_value(actionId);
-        WFIFOSET(7);
-    }
-
-    buySellDialog->setVisible(false);
-}
-
-
 char hairtable[16][4][2] = {
     // S(x,y)  W(x,y)   N(x,y)   E(x,y)
     { { 0, 0}, {-1, 2}, {-1, 2}, {0, 2} }, // STAND
@@ -287,7 +265,7 @@
     sellDialog = new SellDialog();
     sellDialog->setVisible(false);
 
-    buySellDialog = new BuySellDialog(new BuySellListener());
+    buySellDialog = new BuySellDialog();
     buySellDialog->setVisible(false);
 
     inventoryWindow = new InventoryWindow();
Index: src/graphic/graphic.h
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/graphic/graphic.h,v
retrieving revision 1.50
diff -u -r1.50 graphic.h
--- src/graphic/graphic.h	20 Feb 2005 22:57:11 -0000	1.50
+++ src/graphic/graphic.h	23 Feb 2005 17:02:16 -0000
@@ -88,14 +88,6 @@
 };
 
 /**
- * The action listener for the buy or sell dialog.
- */
-class BuySellListener : public gcn::ActionListener {
-    public:
-        void action(const std::string& eventId);
-};
-
-/**
  * 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The
  * topology is as follows:
  *
cvs diff: Diffing src/gui
Index: src/gui/buy.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/gui/buy.cpp,v
retrieving revision 1.6
diff -u -r1.6 buy.cpp
--- src/gui/buy.cpp	8 Jan 2005 01:33:52 -0000	1.6
+++ src/gui/buy.cpp	23 Feb 2005 17:02:16 -0000
@@ -26,6 +26,7 @@
 #include "slider.h"
 #include "scrollarea.h"
 #include "listbox.h"
+#include "../game.h"
 
 #include <sstream>
 
@@ -140,9 +141,11 @@
             }
         }
         setVisible(false);
+        current_npc = 0;
     }
     else if (eventId == "cancel") {
         setVisible(false);
+        current_npc = 0;
     }
 }
 
Index: src/gui/buysell.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/gui/buysell.cpp,v
retrieving revision 1.3
diff -u -r1.3 buysell.cpp
--- src/gui/buysell.cpp	8 Jan 2005 01:33:52 -0000	1.3
+++ src/gui/buysell.cpp	23 Feb 2005 17:02:16 -0000
@@ -23,8 +23,9 @@
 
 #include "buysell.h"
 #include "button.h"
+#include "../game.h"
 
-BuySellDialog::BuySellDialog(gcn::ActionListener *al):
+BuySellDialog::BuySellDialog():
     Window("Shop")
 {
     buyButton = new Button("Buy");
@@ -43,9 +44,9 @@
     sellButton->setEventId("sell");
     cancelButton->setEventId("cancel");
 
-    buyButton->addActionListener(al);
-    sellButton->addActionListener(al);
-    cancelButton->addActionListener(al);
+    buyButton->addActionListener(this);
+    sellButton->addActionListener(this);
+    cancelButton->addActionListener(this);
 
     add(buyButton);
     add(sellButton);
@@ -61,3 +62,25 @@
     delete sellButton;
     delete cancelButton;
 }
+
+void BuySellDialog::action(const std::string& eventId)
+{
+    int actionId = -1;
+
+    if (eventId == "buy") {
+        actionId = 0;
+    }
+    else if (eventId == "sell") {
+        actionId = 1;
+    } else if (eventId == "cancel") {
+        current_npc = 0;
+    }
+    if (actionId > -1) {
+        WFIFOW(0) = net_w_value(0x00c5);
+        WFIFOL(2) = net_l_value(current_npc);
+        WFIFOB(6) = net_b_value(actionId);
+        WFIFOSET(7);
+    }
+
+    setVisible(false);
+}
Index: src/gui/buysell.h
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/gui/buysell.h,v
retrieving revision 1.4
diff -u -r1.4 buysell.h
--- src/gui/buysell.h	15 Jan 2005 17:49:01 -0000	1.4
+++ src/gui/buysell.h	23 Feb 2005 17:02:17 -0000
@@ -31,7 +31,8 @@
  *
  * \ingroup GUI
  */
-class BuySellDialog : public Window {
+class BuySellDialog : public Window, public gcn::ActionListener
+{
     public:
         /**
          * Constructor. The action listener passed will receive "sell", "buy"
@@ -39,12 +40,17 @@
          *
          * @see Window::Window
          */
-        BuySellDialog(gcn::ActionListener *al);
+        BuySellDialog();
 
         /**
          * Destructor.
          */
         ~BuySellDialog();
+        
+        /**
+         * Called when receiving actions from the widgets.
+         */
+        void action(const std::string& eventId);
 
     private:
         gcn::Button *buyButton;
Index: src/gui/npc.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/gui/npc.cpp,v
retrieving revision 1.14
diff -u -r1.14 npc.cpp
--- src/gui/npc.cpp	20 Feb 2005 03:13:27 -0000	1.14
+++ src/gui/npc.cpp	23 Feb 2005 17:02:17 -0000
@@ -108,7 +108,9 @@
             WFIFOB(6) = net_b_value(selectedIndex + 1);
             WFIFOSET(7);
             setVisible(false);
+            current_npc = 0;
             reset();
+            
         }
     }
     else if (eventId == "cancel") {
@@ -119,5 +121,6 @@
         WFIFOSET(7);
         setVisible(false);
         reset();
+        current_npc = 0;
     }
 }
Index: src/gui/npc_text.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/gui/npc_text.cpp,v
retrieving revision 1.4
diff -u -r1.4 npc_text.cpp
--- src/gui/npc_text.cpp	8 Jan 2005 01:33:53 -0000	1.4
+++ src/gui/npc_text.cpp	23 Feb 2005 17:02:17 -0000
@@ -76,4 +76,5 @@
     WFIFOSET(6);
     setText("");
     setVisible(false);
+    current_npc = 0;                                
 }
Index: src/gui/sell.cpp
===================================================================
RCS file: /cvsroot/themanaworld/tmw/src/gui/sell.cpp,v
retrieving revision 1.5
diff -u -r1.5 sell.cpp
--- src/gui/sell.cpp	6 Feb 2005 14:37:26 -0000	1.5
+++ src/gui/sell.cpp	23 Feb 2005 17:02:17 -0000
@@ -27,6 +27,7 @@
 #include "scrollarea.h"
 #include "listbox.h"
 #include "../graphic/graphic.h"
+#include "../game.h"
 
 #include <sstream>
 
@@ -132,9 +133,11 @@
             }
         }
         setVisible(false);
+        current_npc = 0;
     }
     else if (eventId == "cancel") {
         setVisible(false);
+        current_npc = 0;
     }
 }
 
cvs diff: Diffing src/net
cvs diff: Diffing src/resources
>> Command complete (exit code: 0)
Have a nice day

Posted: 23 Feb 2005, 23:44
by Bjørn
Reviewed, tested and committed! Thanks a lot for providing this one as a patch file, and of course for providing it at all. :-)

Closes task #13.