Code Analysis for the version 3285

Source: Internet
Author: User
Tags node server
Turn: coronanimo

ForCodeAnalysis

This is a simple analysis of the server. Because scriptdev2 only adds gem and teleport and defends against Chinese characters, we all understand that, so we will not analyze it.
Thank you very much, xren.CommunityOpen source code spirit. This post is intended to serve as a reference for the first-time study of mangos code. On the other hand, I would like to say that there is no need to release so many versions, make more patches, and send more code to the Forum. What you compiled can only be an entertainment task for others. Of course, I am not a friend here who is planning to make money in the service.
We hope the xren community can make more and better patches in the future. We also hope that some people who have gone astray will do some practical work early. In a word, people can communicate with each other to make progress.
Send this articleArticleI have been thinking about it for a long time, because I am afraid that because of this, many "new versions" will appear, so that xren will lose enthusiasm for this kind of activity that does not respect copyright.
I hope you can think of xren when using this, especially when setting experiences. This is because the code is not troublesome, but it provides an idea to change the parameter settings without re-compiling.
In fact, mangoscript's support for Lua is commendable.
The body is shown below.

Code Analysis for the version of the Cross-node Server)
Tool: SVN/check modifications.
1. Shared:
A) Comment. h
-# Define expected_mangos_client_build {5875,6005, 0}
+ # Define expected_mangos_client_build {5875,6005, 6141,0}
Added version 6141 support (1.12.3)
2. realmd
Changed some prompts.
3. mangosd
Changed some prompts.
4. Game
A) creature. cpp
-M_deathtimer (0), m_respawntime (0), m_respawndelay (25), m_corw.delay (60), m_respawnradius (0.0 ),
+ M_deathtimer (0), m_respawntime (0), m_respawndelay (25), m_correntdelay (sworld. getconfig (config_crorent_delay), m_respawnradius (0.0 ),
Purpose: Read the time when the corpse disappears from the configuration file.

B) forumula. h
-Inline uint32 basegain (uint32 pl_level, uint32 mob_level)
-{
-If (mob_level> = pl_level)
-Return (pl_level * 5 + 45) * (20 + mob_level-pl_level)/10 + 1)/2;
-Else
-{
-Uint32 gray_level = getgraylevel (pl_level );
-If (mob_level> gray_level)
-{
-Uint32 ZD = getzerodifference (pl_level );
-Return (pl_level * 5 + 45) * (ZD + mob_level-pl_level)/ZD;
-}
-Return 0;
-}
-}
+ Inline uint32 basegain (uint32 pl_level, uint32 mob_level)
+ {
+ If (pl_level = mob_level)
+ Return (pl_level * 5 + 45 );
+ Else if (mob_level> pl_level)
+ Return static_cast <uint32> (pl_level * 5 + 45) * (1 + 0.05 * (mob_level-pl_level) + 0.5 );
+ Else
+ {
+ Uint32 gray_level = getgraylevel (pl_level );
+ If (mob_level> gray_level)
+ {
+ Uint32 ZD = getzerodifference (pl_level );
+ Return (pl_level * 5 + 45) * (1-(pl_level-mob_level)/ZD ));
+}
+ Return 100/(pl_level-mob_level );//??? Return 0;
+}
+}
The role of this section is to change over 5 levels without experience. But this has been corrected in the latest mangos version. In addition, the formula for obtaining experience is more objective.
You can consider making changes based on the latest version. Add your own experience code to return 0.

+ // doubling the member experience
+ If (pl-> getsession ()-> getsecurity ()> = 1)
+ return (uint32) (xp_gain * sworld. getrate (rate_vip_xp_kill) * sworld. getrate (rate_xp_kill);
+ else if (pl-> getlevel () + return (uint32) (xp_gain * sworld. getrate (rate_xp_kill);
+ else
+ return (uint32) (xp_gain * sworld. getrate (rate_user_max_xp);

-Return (uint32) (xp_gain * sworld. getrate (rate_xp_kill ));
This function is used to increase the member experience. If the membership level is exceeded, only the 10rate_user_max_xp experience can be obtained. I feel unnecessary.

C) Guild. cpp
Change the English prompt information to utf8. I will not list them here.
Rows 1 and 91
D) level0.cpp
The latest version has not been changed.
E) player. cpp
-Initstatsforlevel (1, false, false );
+ Initstatsforlevel (sworld. getconfig (config_level_first), false, false); // initial birth character level
Birth character level, not explained.

-
-Uint16 DEST;
+
+ Uint16 DEST;
+ Setmoney (sworld. getconfig (config_my_money); // initial character money
348 rows, born with money, not explained

-Givexp (XP, null );
+ If (this-> getsession ()-> getsecurity ()> = 1 | this-> getlevel () <sworld. getconfig (rate_user_max_level ))
+ {
+ Givexp (XP, null );
+}
+ Else
+ {
+ Givexp (88, null );
+}
Row 3 is used to control the membership and non-member level. If you are not a member and have reached the highest level, you can only get 88 points of experience.
F) World. cpp
-
+ Rate_values [rate_vip_xp_kill] = sconfig. getfloatdefault ("rate. vip_xp.kill", 2); // double member experience
+ Rate_values [rate_user_max_level] = sconfig. getfloatdefault ("rate. user_max.level", 90); // set the non-member level
+ Rate_values [rate_user_max_xp] = sconfig. getfloatdefault ("rate. user_max.xp", 100); // set the maximum experience of non-members
+ M_configs [config_my_money] = sconfig. getintdefault ("mymoney", 8); // initial character money
+ M_configs [config_level_first] = sconfig. getintdefault ("levelfirst", 1); // initial birth character level
+ M_configs [config_crow._delay] = sconfig. getintdefault ("mycrow.delay", 60); // The time when the initial monster remains.
Here are several additional configurations for reading, which will be used later.
G) World. h
+ Config_my_money, // initial character money
+ Config_level_first, // initial birth character level
+ Config_cropse_delay, // The time when the initial monster remains.
+ Rate_vip_xp_kill, // double member experience
+ Rate_user_max_level, // non-member level settings
+ Rate_user_max_xp, // maximum number of non-member experience settings
+ Max_rates
Here is the header file modification corresponding to world. cpp.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.