ReHLDS, Reverse-engineered HLDS

Dr.CYBORG

Dr. CYBORG
Staff member
May 14, 2018
27
39
13
Bangalore
Credits
₹61
Points
0
0 Banked
#1
ReHLDS is the result of the reverse engineering of the original HLDS (build 6152/6153) using DWARF debugging information built into the linux version of HLDS, engine_i486.so.
In the process of reverse engineering, many shortcomings and potential bugs were discovered and corrected.

References:
Motivation:
The main motivation - the valve does nothing and there is no possibility to correct bugs normally.​

Objectives:
  • Provide a more stable HLDS with an extended API for mods and plugins.
  • Optimizing performance.

Current status:
The engine is stable, almost all functions work correctly.​

How to use?
ReHLDS is fully compatible with the original HLDS. All that is required of you is to load the rehlds binary files and replace the original swds.dll / engine_i486.so. In this case, before the engine is replaced, the server must be updated via steamcmd to the latest 6xxx + beta.​
The compiled files are available (choose .zip with the most recent modification date).​
The bin directory contains 2 subdirectories, 'bugfixed' and 'pure'.​
' pure ' is designed to work exactly like the original HLDS from the valve.​
' bugfixed ' contains some fixes and improvements.​
Attention!ReHLDS files are binary incompatible with the original HLDS, as compiled by another compiler. This means that the plugins doing binary code analysis (Orpheu for example) will probably not work with rehlds. Accordingly, dproto will not work either. But for most plugins there is already an improved replacement.​

What did this give us?
It became possible not just to learn the engine, but it's also easy to make changes to it. Previously, this required writing patch memory modules, which is quite laborious. This is only useful for fixing critical bugs for which exploits have already been written, since for every small defect writing patches is too dreary. Now you can fix any errors of the engine without any problems and do its improvements. In the future, the HLDS from Valve can be forgotten and maintained by the server engine independently.​
A report on the optimizations for the month was published.

information is mostly of a technical nature, so I will not translate everything, but only what is needed to evaluate the results. They can be viewed in the form of . Who cares about the technical details of the tests, it is better to read in the original, there English is not difficult.

Tests were made under windows on 6 different processors from i3 to i7 and with different combinations of different engine libraries, mod and metamod, but without amxmodx.
On each processor with different sets of libraries, one and the same recorded 20-minute 16x16 match on the de_aztec card with sys_ticrate 100 was started in turn, one by one. The testing system is built in such a way that instead of the system function calls, their finished result is returned immediately without delay. Thus, the processor always executes only the code of the game server and the playback of the recorded match takes less time than its recording, in which the system functions were performed in full. The total time depends on the processor's performance and the optimization of all the server's libraries.

Used types of engine libraries:
  • Stock: HLDS от Valve
  • Pedantic optimizations (P.Opt) : ReHLDS with optimizations that do not violate binary compatibility
  • Optimized (Opt) : ReHLDS with all possible optimizations and corrections

The types of libraries used are:
  • Stock: mp.dll от Valve
  • Optimized : third-party mp.dll with optimization of several mathematical functions

Used types of metamod libraries:
  • Stock : standard metamod-am
  • Optimized : metamod-am with some offline forwards disabled

Evaluation of results:
  • Optimizing metamod yields 20% to 30% performance gains, but somewhat truncates its functionality.
  • A set of binary-compatible optimizations ReHLDS gives from 65% to 110% increment. In this case, the operation of the server is completely identical to that of conventional HLDS.
  • The inclusion of all optimizations and corrections gives an 11% increase over the previous point. At the same time, some mathematical functions will produce an error of less than 0.01%, which practically does not affect the server's performance.
  • Optimization of the mod gives about 6% of the gain.

Conclusion:
The figures speak for themselves. ReHLDS works more than 2 times faster than regular HLDS.​
 
Top Bottom