Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

EE2.7 mini-optimization guide


DFA
 Share

Recommended Posts

I will use this thread to provide suggestions for improvement
here are just a few of the basics

Client
- Consider reducing the amount of forms
- Move DirectX initialization to sub Main (load in background so user doesn't have to wait)
- Removed all graphics over 10KB from forms, use code to load graphics from external files (bmp)  This will reduce compile time, and reduce the size of the exe.
- in modConstants add data types to all variables, variants are big and slow

-  Doesn't need to be an array, takes up way too much memory.
Public Map() As MapRec
Public TempTile() As TempTileRec

- Remove module RegUnregActiveX, replace with external program, such as Eclipse Library Installer (which should handle the registering)

- In Public Sub DrawText, add data types to X and Y, avoid using variants anywhere unless specifically needed

- Remove error handling in sub FileExists, and correct it so errors couldn't occcur.

- Remove module modSCapture, would result in less memory usage, and faster compile time.  Too much code for such a small feature, windows supports screenshotting using button

- Alter code to use variables instead of constantly accessing hard drive, for example, the PlaySound sub contains
If ReadINI("CONFIG", "Music", App.Path & "\config.ini")
Every time a sound is played, it accesses the user's hard drive to check the contents of config.ini.

- Replace variant return string functions with their String return type versions (check references at bottom)

- Search all code for variables without data types, such as variable nTwipsPerInch

- String packets need to be converted to byte array packets
- DirectDraw code needs major improvements
i recommend using the byte array and DirectDraw rendering engine from Mirage Source 4.
Mirage Source 4 provides many optimizations that can be implemented directly into Eclipse.  I do not suggest using Mirage Source 4 for any purpose other than a code reference

Server
- Consider removing IOCP, it improves server performance, but the library isn't perfect and contains bugs.  Newer versions of the DLL do not work.  Winsock is fine for smallscale games.  if CPU usage becomes a problem with winsock, IOCP may help.

- Consider removing SadScripting, it impacts performance

- Remove ALL timer controls and replace with a server loop. Timers use CPU, memory, and are inaccurate

- Most of the client suggestions apply to the server as well.

Basic optimizations
- Implement short-circuit evaluation
for example

```
                If GetAsyncKeyState(VK_LEFT) >= 0 And DirLeft Then
                    DirLeft = False
                End If

```
can be altered to

```
                If GetAsyncKeyState(VK_LEFT) >= 0 Then
                    If DirLeft Then
                        DirLeft = False
                    End If
                End If

```
But if both parts share a else statement, its generally acceptable to leave the statement without splitting it up

============================================================

Avoid comparing to True or False with if statements

```
If CanMove = True Then

```
can be altered to
```
If CanMove Then

If Not CanMove Then

```
========================================================

Use Select Case instead of a several If statements.  Case statement can improve performance of poor use of if statements, otherwise, there is no performance increase.  This will generally improve the readability of the code

Empty String "" can be replaced with vbNullString

avoid checking against empty strings
if getPlayerName(Index) <> vbNullstring Then
can be changed to…
if LenB(getPlayeName(index) > 0 Then

=========================================================

-For clear functions on both the client and the server, use the ZeroMemory function instead of setting everything to 0.  Strings must be set to vbNullString though.

- Use With statement for REC and other types

Reference
here are the return String versions of commonly used String functions with variant return type

Chr to Chr$
ChrB to ChrB$
ChrW to ChrW$
Format to Format$
LCase to LCase$
Left to Left$
LTrim to LTrim$
LeftB to LeftB$
Mid to Mid$
MidB to MidB$
Right to Right$
RightB to RightB$
UCase to UCase$

ChrW$ is faster than Chr$
AscW is faster than Asc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...