Alina 234 Posted March 20, 2015 Share Posted March 20, 2015 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) Hi everyone! Today I want to show you how to make the big notice work. You may have already noticed that the command /b only works for you. No one else will get messages sent by /b. As soon as we're finished, /b will work without any flaws! The best thing about this: We're not going to add any functions! We only alter them and edit a packet. We also make sure our code is compatible with old function calls, so /n will still work even when the source needs it. But enough chit-chat. Here's the guide! I made sure everybody can understand what I'm writing so I made simple steps. Quote *** Disclaimer (kinda) *** I hereby declare that the changes I made are all by myself. I did not steal from anyone. Therefore for this guide I am the author. If anyone wants to copy my guide and post it anywhere he's free to do as long as he mentions the original author. I do not provide or share the source code or anything else protected by copyright. If something breaks I'm not the one to blame at. Always make sure to test changes. Never implement them on production releases, always use test distributions before! If you find any flaws, may it be regarding security or something else you're free to tell me so. I'm learning, as we all do, so I'm in no way too proud to admit I'm making mistakes. I'll correct them as soon as possible of course. 1.) which files do we need to edit? - cmd_general.cpp - cmd.h - cmd_gm.cpp - packet.h - input_p2p.cpp - input_db.cpp 2.) what are we planning to do? First we observe how the game handles our beloved notice-function. As soon as we backtrace the function calls, we'll learn that our /n command refers to ACMD(do_notice) which forwards the argument given by our command to the BroadcastNotice-function where a p2p-packet is created (to ensure that other core instances also send the message). In the last step the SendNotice-function is being called. It uses a struct to send the message to everyone connected to this core instance. Note that the packet triggers our SendNotice function in other game core instances. So what can we do? The simplest way is to extend our functions. We'll add a bool variable which we can set to true if we want to use the big notices. We also have to edit the packet since we need to carry our bool variable with it: Other core instances need to know wheter they'd use the big notices or not. 3.) First altering the functions What we want to edit in this section: - cmd_general.cpp - cmd.h - cmd_gm.cpp At first open cmd_gm.cpp. Find void BroadcastNotice(const char * c_pszBuf) and replace with: void BroadcastNotice(const char * c_pszBuf, bool IsBig) Then find: void SendNotice(const char * c_pszBuf) and replace with: void SendNotice(const char * c_pszBuf, bool IsBig) Then find struct notice_packet_func and replace it with this: struct notice_packet_func { const char * m_str; bool m_big; notice_packet_func(const char * str, bool big = false) : m_str(str), m_big(big) { } void operator () (LPDESC d) { if (!d->GetCharacter()) return; d->GetCharacter()->ChatPacket(m_big == true ? CHAT_TYPE_BIG_NOTICE : CHAT_TYPE_NOTICE, "%s", m_str); } }; You just have to compare your struct with the new one. I simply added a new bool variable and used it at the end to determine if it's a big notice or not. You can simply copy pastarino those 3 lines and are ready to go Next is the SendNotice-function. There you'll find std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_packet_func(c_pszBuf)); Replace it with std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_packet_func(c_pszBuf, IsBig)); At last find ACMD(do_big_notice) And replace it's content with BroadcastNotice(argument, true); Then find For now we can close cmd_gm.cpp Next open cmd.h Find extern void SendNotice(const char * c_pszBuf); // 이 게임서버에만 공지 extern void BroadcastNotice(const char * c_pszBuf); // 전 서버에 공지 and replace them with: extern void SendNotice(const char * c_pszBuf, bool IsBig = false); // 이 게임서버에만 공지 extern void BroadcastNotice(const char * c_pszBuf, bool IsBig = false); // 전 서버에 공지 we're finished with cmd.h Now open cmd_general.cpp Find extern void BroadcastNotice(const char * c_pszBuf); and replace with: extern void BroadcastNotice(const char * c_pszBuf, bool IsBig); We're done with cmd_general.cpp too. Finish with opening input_db.cpp And there find extern void SendNotice(const char * c_pszBuf); and replace with extern void SendNotice(const char * c_pszBuf, bool IsBig = false); Compile and we're done! If you type in /b test you'll get the following result: you and everyone connected to the same core as you will receive the big notice. Everyone not connected to your core will receive a normal notice. 4.) Editing the packet In this section we want to edit the notice packet sent to other core instances by p2p so everyone will be able to see the big notice instead of our normal one. Files we want to edit: packet.h input_p2p.cpp cmd_gm.cpp First open packet.h Search for SPacketGGNotice and add the following variable: bool bIsBig; Close packet.h and open input_p2p.cpp There we search for int CInputP2P::Notice(LPDESC d, const char * c_pData, size_t uiBytes) and replace the following line SendNotice(szBuf); with SendNotice(szBuf, p->bIsBig); Now close input_p2p.cpp and open cmd_gm.cpp again. In our SendNotice-function we just have to find p.lSize = strlen(c_pszBuf) + 1; and add the following line below: p.bIsBig = IsBig; That's all! Save and compile Best Regards, Alina 27 1 1 11 2 29 Link to comment Share on other sites More sharing options...
dukaibalu1 39 Posted March 20, 2015 Share Posted March 20, 2015 Please image screen! Link to comment Share on other sites More sharing options...
Alina 234 Posted March 20, 2015 Author Share Posted March 20, 2015 (edited) On my way You can just type in /b hey there! I'm using big notices. (totally no reference) Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Ken 904 Posted March 20, 2015 Share Posted March 20, 2015 Good job. Kind Regards Ken 1 Do not be sorry, be better. Link to comment Share on other sites More sharing options...
dukaibalu1 39 Posted March 20, 2015 Share Posted March 20, 2015 Thank you! Nice work! Link to comment Share on other sites More sharing options...
llReonas 29 Posted March 20, 2015 Share Posted March 20, 2015 Good. Link to comment Share on other sites More sharing options...
Former Staff flygun 304 Posted March 22, 2015 Former Staff Share Posted March 22, 2015 good job :/ but why don't you use code? oh and excuse my bad english ... but i think this will affect on ox-event ?? best regards FlyGun Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 22, 2015 Premium Share Posted March 22, 2015 Where you tell to notice_packet_func that is a big notice? If I am not missing something, nowhere Link to comment Share on other sites More sharing options...
Alina 234 Posted March 22, 2015 Author Share Posted March 22, 2015 Thanks for the kind replies! flygun, as far as I know OX is using notice_in_map. That already has a built-in way to use big notices instead of small ones - but only for the map. Cataclismo, I did with the bool bIsBig. The value will be set to the IsBig-variable sent to the function (I changed the ACMD to call the function with true. It's false by default because i definde it in the header to be false. Only when the function is called with true like in ACMD it actually will be true. The packet just carries the variable) 2 Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 22, 2015 Premium Share Posted March 22, 2015 This is the default structure of SendNotice, right? void SendNotice(const char * c_pszBuf, bool isBig = false) { const DESC_MANAGER::DESC_SET & c_ref_set = DESC_MANAGER::instance().GetClientSet(); std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_packet_func(c_pszBuf)); } Shouldn't it be like that? std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_packet_func(c_pszBuf, isBig)); 1 Link to comment Share on other sites More sharing options...
Alina 234 Posted March 23, 2015 Author Share Posted March 23, 2015 Oops, totally forgot about that. I'm editing it right now. I first developed it and then wrote the guide, that's why I missed it by accident Thanks! Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 23, 2015 Premium Share Posted March 23, 2015 Oops, totally forgot about that. I'm editing it right now. I first developed it and then wrote the guide, that's why I missed it by accident Thanks! I thought so. No problem. Link to comment Share on other sites More sharing options...
MaRRaTPL 3 Posted March 26, 2015 Share Posted March 26, 2015 cmd_gm.cpp: In function 'void SendNotice(const char*, bool)': cmd_gm.cpp:1156: error: 'isBig' was not declared in this scope cmd_gm.cpp: In function 'void do_set_stat(CHARACTER*, const char*, int, int)': cmd_gm.cpp:3939: warning: NULL used in arithmetic gmake: *** [OBJDIR/cmd_gm.o] Error 1 gmake: *** Waiting for unfinished jobs.... Link to comment Share on other sites More sharing options...
Think 117 Posted March 26, 2015 Share Posted March 26, 2015 MaRRaTPL, replace std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_packet_func(c_pszBuf, isBig)); with std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_packet_func(c_pszBuf, IsBig)); (Note the case change on the last variable, that's the only thing I changed). 1 Link to comment Share on other sites More sharing options...
daredevil09 5 Posted March 30, 2015 Share Posted March 30, 2015 (edited) Tested and i have problem. Now appears notice to other player with /b, but when i write in chat "/b Good night" it's like "/n Good night". Screen: /b comand must be like: Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Alina 234 Posted March 30, 2015 Author Share Posted March 30, 2015 According to your error description I guess you missed a step or made a small mistake maybe. You told us that other players are getting the /b announces. So the only error is the bool variable. There something is not correct and that's why you don't see the /b board If you want, you can make screens of the changed functions and I can help you with that. 1 Link to comment Share on other sites More sharing options...
adi97ida 6 Posted March 30, 2015 Share Posted March 30, 2015 extern void BroadcastNotice(const char * c_pszBuf, bool IsBig = true); Why aren't you setting IsBig to true ?? Link to comment Share on other sites More sharing options...
daredevil09 5 Posted March 30, 2015 Share Posted March 30, 2015 (edited) According to your error description I guess you missed a step or made a small mistake maybe. You told us that other players are getting the /b announces. So the only error is the bool variable. There something is not correct and that's why you don't see the /b board If you want, you can make screens of the changed functions and I can help you with that. I checked 3 times and what I have implemented is the same as your tutorial. Me and players see /b but appears like /n announces. I did screen at all modification, like your tutorial: https://metin2.download/picture/9B09wK5hn79SLtkyqQ5423GpSpsI1ZVB/.png?1 https://metin2.download/picture/hycbhY6y71xRJGiYKhk3gazL4eByh4s1/.png?1 https://metin2.download/picture/7kqJ761KQ3Q75F5zSUX0vv6tNh6cB3Za/.png?1 https://metin2.download/picture/PKw031QGGKbvk8tr59IjgGHTxlBpmS6t/.png?1 https://metin2.download/picture/cE502b9K5Pr3tUzv1s649K2z2gPLzH7y/.png?1 https://metin2.download/picture/9e9iu6oBolc3xFr259uSmj14uNo46L87/.png?1 https://metin2.download/picture/0dfsTsS8d8g79j3Cu1fY4E4s5vuVW5f9/.png?1 https://metin2.download/picture/06cka216I368Sjf59DI5NL8rVJ5AAQyq/.png?1 https://metin2.download/picture/VSEABpuWeCTR7fYntr5opE1cBbbvI10a/.png?1 https://metin2.download/picture/YrYF5lvoSULRpC3aPlj5gV8ZOtR46f60/.png?1 https://metin2.download/picture/XD8aUy5jgi4mFWiDQK5JBol8sikAa1qP/.png?1 Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Former Staff flygun 304 Posted March 30, 2015 Former Staff Share Posted March 30, 2015 (edited) According to your error description I guess you missed a step or made a small mistake maybe. You told us that other players are getting the /b announces. So the only error is the bool variable. There something is not correct and that's why you don't see the /b board If you want, you can make screens of the changed functions and I can help you with that. I checked 3 times and what I have implemented is the same as your tutorial. Me and players see /b but appears like /n announces. I did screen at all modification, like your tutorial: https://metin2.download/picture/9B09wK5hn79SLtkyqQ5423GpSpsI1ZVB/.png?1 https://metin2.download/picture/hycbhY6y71xRJGiYKhk3gazL4eByh4s1/.png?1 https://metin2.download/picture/7kqJ761KQ3Q75F5zSUX0vv6tNh6cB3Za/.png?1 https://metin2.download/picture/PKw031QGGKbvk8tr59IjgGHTxlBpmS6t/.png?1 https://metin2.download/picture/cE502b9K5Pr3tUzv1s649K2z2gPLzH7y/.png?1 https://metin2.download/picture/9e9iu6oBolc3xFr259uSmj14uNo46L87/.png?1 https://metin2.download/picture/0dfsTsS8d8g79j3Cu1fY4E4s5vuVW5f9/.png?1 https://metin2.download/picture/06cka216I368Sjf59DI5NL8rVJ5AAQyq/.png?1 https://metin2.download/picture/VSEABpuWeCTR7fYntr5opE1cBbbvI10a/.png?1 https://metin2.download/picture/YrYF5lvoSULRpC3aPlj5gV8ZOtR46f60/.png?1 https://metin2.download/picture/XD8aUy5jgi4mFWiDQK5JBol8sikAa1qP/.png?1 i got same problem ... Edited August 19, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Alina 234 Posted March 30, 2015 Author Share Posted March 30, 2015 in the BroadcastNotice-function change SendNotice(c_pszBuf); to SendNotice(c_pszBuf, IsBig); Otherwise the bool variable won't be given to the struct so people will only receive the normal shouts 5 Link to comment Share on other sites More sharing options...
daredevil09 5 Posted March 31, 2015 Share Posted March 31, 2015 in the BroadcastNotice-function change SendNotice(c_pszBuf); to SendNotice(c_pszBuf, IsBig); Otherwise the bool variable won't be given to the struct so people will only receive the normal shouts Now it's ok, thx Alina Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted March 31, 2015 Premium Share Posted March 31, 2015 extern void BroadcastNotice(const char * c_pszBuf, bool IsBig = true); Why aren't you setting IsBig to true ?? Because if you do that then all notices will be sent as big, even the notices sent with /n. We need the default value to be false, and only when we send notices with /b to tell the function that we want a big one. 2 Link to comment Share on other sites More sharing options...
Alina 234 Posted March 31, 2015 Author Share Posted March 31, 2015 extern void BroadcastNotice(const char * c_pszBuf, bool IsBig = true); Why aren't you setting IsBig to true ?? Because if you do that then all notices will be sent as big, even the notices sent with /n. We need the default value to be false, and only when we send notices with /b to tell the function that we want a big one. Quite correct. It's about defining it in the headers. We want to make it compatible with older function calls. There are several examples where the source calls our changed functions. If we'd change it to true, then every message would be in big notice style, not our small notice-style. Of course you can do so. But then you'd have to change your /n command to give "false" to your argument. So server messages and /b would be big notice and /n would be small notice. That's also a way you'd do it. It depends on your needs Feel free to adapt the source changes to your needs Link to comment Share on other sites More sharing options...
Premium phayara 424 Posted April 1, 2015 Premium Share Posted April 1, 2015 root@host:/usr/src/mainline_released/mainline_sg/Srcs/Server/game/src # gmake compile BattleArena.cpp BattleArena.cpp: In function 'long int battle_arena_event(LPEVENT, long int)': BattleArena.cpp:105: error: call of overloaded 'BroadcastNotice(const char*)' is ambiguous cmd.h:55: note: candidates are: void BroadcastNotice(const char*, bool) cmd.h:56: note: void BroadcastNotice(const char*) BattleArena.cpp:112: error: call of overloaded 'BroadcastNotice(const char*)' is ambiguous cmd.h:55: note: candidates are: void BroadcastNotice(const char*, bool) cmd.h:56: note: void BroadcastNotice(const char*) BattleArena.cpp:122: error: call of overloaded 'BroadcastNotice(const char*)' is ambiguous cmd.h:55: note: candidates are: void BroadcastNotice(const char*, bool) cmd.h:56: note: void BroadcastNotice(const char*) BattleArena.cpp: In member function 'bool CBattleArena::Start(int)': BattleArena.cpp:247: error: call of overloaded 'BroadcastNotice(char [1024])' is ambiguous cmd.h:55: note: candidates are: void BroadcastNotice(const char*, bool) cmd.h:56: note: void BroadcastNotice(const char*) BattleArena.cpp:248: error: call of overloaded 'BroadcastNotice(const char*)' is ambiguous cmd.h:55: note: candidates are: void BroadcastNotice(const char*, bool) cmd.h:56: note: void BroadcastNotice(const char*) gmake: *** [OBJDIR/BattleArena.o] Error 1 root@host:/usr/src/mainline_released/mainline_sg/Srcs/Server/game/src # Please help me.. Problem solved, my mistake sorry Link to comment Share on other sites More sharing options...
Premium phayara 424 Posted April 1, 2015 Premium Share Posted April 1, 2015 New error.. cmd_gm.cpp: In function 'void BroadcastMonarchNotice(BYTE, const char*)': cmd_gm.cpp:1237: error: 'struct TPacketGGMonarchNotice' has no member named 'bIsBig' cmd_gm.cpp:1237: error: 'IsBig' was not declared in this scope cmd_gm.cpp: In function 'void do_set_stat(CHARACTER*, const char*, int, int)': cmd_gm.cpp:3940: warning: NULL used in arithmetic gmake: *** [OBJDIR/cmd_gm.o] Error 1 root@host:/usr/src/mainline_released/mainline_sg/Srcs/Server/game/src # Link to comment Share on other sites More sharing options...
Recommended Posts