SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 03-25-14, 10:38 AM   #3046
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by gap View Post
Trust me or not, the one possible linear function which interpolates the two extremes derived min. signal strength (x1) - derived min signal strength x game's nighttime multiplier, is the one I have suggested at post #3032
You're hung up on something. The code I posted is a linear function. I tested it in the debugger to ensure it was linear. Giving available light as 0.499999 results in minimum signal strength of original minimum signal strength. Giving available light as 0.283 (game's nighttime value) results in minimum signal strength * 3.0. Giving available light as 0.3915 (half-way point) results in minimum signal strength * 1.5. How is that not linear?
TheDarkWraith is offline   Reply With Quote
Old 03-25-14, 11:03 AM   #3047
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
You're hung up on something. The code I posted is a linear function. I tested it in the debugger to ensure it was linear. Giving available light as 0.499999 results in minimum signal strength of original minimum signal strength. Giving available light as 0.283 (game's nighttime value) results in minimum signal strength * 3.0. Giving available light as 0.3915 (half-way point) results in minimum signal strength * 1.5.
At last we are talking again the same (universal) language: numbers

Quote:
Originally Posted by TheDarkWraith View Post
How is that not linear?
you forget something:

our extremes are minimum signal strength and minimum signal strength * 3.
Divide both terms by minimum signal strength and you get 1 and 3. The midpoint between 1 and 3 is not 1.5; it is 2

Maybe (yet another) graphical comparison between my function (in blue) and your one (in red), can help:

__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 03-25-14, 01:13 PM   #3048
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Looked back over the code for the minimum signal strength adjustment and noticed that I wasn't accounting for 0 based numbers I rewrote those two functions to take into account 0 based numbers and also to clean it up (original code was fugly!) and to add some error checking into it also (to account for user errors - entering wrong values for variables)

Now it's linear

Code:
TEST AL,AL                                     ; (Check_Adjust_Nightime_Minimum_Signal_Strength_For_Other_Units_Visual_Sensor) tests whether is daytime (0)
JNE SHSim_act.089431A4                         ; if already nighttime then jump
PUSH EAX                                       ; saves EAX to stack
PUSH ECX                                       ; saves ECX to stack
PUSH ESI                                       ; saves ESI to stack
PUSH 48                                        ; saves offset needed in TDWData to stack (start of nighttime value for other units)
CALL SHSim_act.Load_TDWData_Address_Into_EAX   ; calls Load_TDWData_Address_Into_EAX
FLD DWORD PTR DS:[EAX]                         ; loads start of nighttime value for other units onto top of floating point stack
MOV ECX,DWORD PTR DS:[EBX+48]                  ; loads pointer to table of offsets into ECX
MOV ECX,DWORD PTR DS:[ECX+4]                   ; loads an offset into ECX
FLD DWORD PTR DS:[EBX+ECX+28]                  ; loads current available light onto top of floating point stack
FCOMIP ST,ST(1)                                ; compares current available light to start of nighttime value for player's unit
JNB SHORT SHSim_act.0894319A                   ; if current available light is greater than or equal to start of nighttime value for
PUSH 0                                         ; saves 0 to stack (need start of rdata section)
CALL SHSim_act.Load_rdata_Address_Into_EAX     ; calls Load_rdata_Address_Into_EAX
MOV ESI,EAX                                    ; saves start of rdata section to ESI
ADD EAX,0FB1C                                  ; adds offset needed to EAX (sunlight value - used to determine if nighttime)
FLD DWORD PTR DS:[EAX]                         ; loads sunlight value - used to determine if nighttime onto top of floating point stack
FSUBP ST(1),ST                                 ; subtracts ST0 (sunlight value - used to determine if nighttime) from ST1 (start of nighttime value) and stores result in ST1 and pops top of floating point stack (gets range)
FLDZ                                           ; loads 0.0 onto top of floating point stack
FCOMIP ST,ST(1)                                ; compares ST0 (0.0) to ST1 (range) and pops top of floating point stack
JNB SHORT SHSim_act.0894319A                   ; if negative value for range then jump
FLD1                                           ; loads 1.0 onto top of floating point stack
FXCH ST(1)                                     ; swaps ST0 (1.0) and ST1 (range)
FLD DWORD PTR DS:[EBX+ECX+28]                  ; loads current available light onto top of floating point stack
FSUB DWORD PTR DS:[EAX]                        ; subtracts sunlight value - used to determine if nighttime from ST0 (current available sunlight)
FLDZ                                           ; loads 0.0 onto top of floating point stack
FCOMI ST,ST(1)                                 ; compares ST0 (0.0) to ST1 (result) - have to account for possible floating point error
JBE SHORT SHSim_act.0894315C                   ; if before or equal then jump
FST ST(1)                                      ; saves 0.0 to ST1 (result) - sets new result to 0.0
FSTP ST                                        ; pops top of floating point stack - removes 0.0
FDIVRP ST(1),ST                                ; divides ST0 (result) by ST1 (range) and stores result in ST1 and pops top of floating point stack
FSUBR ST,ST(1)                                 ; subtracts ST0 (result) from ST1 (1.0) and stores result in ST0 - gets % of range
ADD ESI,0FAB4                                  ; add offset needed to ESI (Constant 3.0 - nighttime multiplier)
FLD DWORD PTR DS:[ESI]                         ; loads constant 3.0 onto top of floating point stack (nighttime multiplier)
PUSH 4C                                        ; saves offset needed in TDWData to stack (nightime multiplier addition for other units)
CALL SHSim_act.Load_TDWData_Address_Into_EAX   ; calls calls Load_TDWData_Address_Into_EAX
FADD DWORD PTR DS:[EAX]                        ; adds nighttime multiplier addition for other units to nighttime multiplier
FSUB ST,ST(2)                                  ; subtracts ST2 (1.0) from ST0 (total nighttime multiplier) and stores result in ST0 - this converts to 0 based
FLDZ                                           ; loads 0.0 onto top of floating point stack - is possible that user set multiplier addition to negative value thus adjusted nighttime multiplier could be negative!
FCOMI ST,ST(1)                                 ; compares ST0 (0.0) to ST1 (adjusted nighttime multiplier 0 based)
JBE SHORT SHSim_act.0894317D                   ; if before or equal then jump
FST ST(1)                                      ; saves 0.0 to ST1 (adjusted nighttime multiplier)
FSTP ST                                        ; pops top of floating point stack - removes 0.0
FMULP ST(1),ST                                 ; mutiplies % of range by nighttime multiplier for other units 0 based and stores result in ST1 and pops top of floating point stack
FADDP ST(1),ST                                 ; adds ST0 (result) to ST1 (1.0) and stores result in ST1 and pops top of floating point stack - this converts back to 1 based
FLD DWORD PTR SS:[ESP+20]                      ; loads minimum signal strength onto top of floating point stack
FMULP ST(1),ST                                 ; multiplies ST1 (adjusted nighttime multiplier) by ST0 (minimum signal strength) and stores result in ST1 and pops top of floating point stack
PUSH ECX                                       ; creates temp variable
FST DWORD PTR SS:[ESP]                         ; saves new adjusted minimum signal strength to stack
MOVSS XMM0,DWORD PTR SS:[ESP]                  ; loads new adjusted minimum signal strength into XMM0
ADD ESP,4                                      ; deletes temp variables
ADD DWORD PTR SS:[ESP+0C],10                   ; sets new return value
0894319A:
FSTP ST                                        ; pops top of floating point stack
POP ESI                                        ; restores ESI
POP ECX                                        ; restores ECX
POP EAX                                        ; restores EAX
XORPS XMM2,XMM2                                ; zeroes out XMM2
TEST AL,AL                                     ; tests whether it's daytime (0)
089431A4:
RETN                                           ; returns to caller
TheDarkWraith is offline   Reply With Quote
Old 03-25-14, 01:22 PM   #3049
tonschk
Admiral
 
Join Date: Mar 2007
Posts: 2,200
Downloads: 172
Uploads: 0
Default



__________________
What we do in life echoes in Eternity
tonschk is offline   Reply With Quote
Old 03-25-14, 02:07 PM   #3050
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

v1.0.159.0 released. See post #1

Starting with v1.0.159.0 rewrote the Player's unit visual sensor affected by available light and Units visual sensor affected by available light (does not affect player's unit) patches due to non-linearity found (not accounting for 0 based numbers) and to add some error checking (in case user enters incorrect values for variables in patch file) and because the code was FUGLY!
TheDarkWraith is offline   Reply With Quote
Old 03-25-14, 02:32 PM   #3051
volodya61
Ocean Warrior
 
volodya61's Avatar
 
Join Date: Feb 2012
Location: Rostov-on-Don, local time GMT+4
Posts: 3,300
Downloads: 374
Uploads: 0


Default

Quote:
Originally Posted by TheDarkWraith View Post
v1.0.159.0 released. See post #1
Thank you TDW

There are three patches for the SHSim.act.. correct?
__________________
.
Where does human stupidity end?

.


El sueño de la razón produce monstruos © - and for some people awakening will be cruel
volodya61 is offline   Reply With Quote
Old 03-25-14, 02:45 PM   #3052
THE_MASK
Ace of the deep .
 
THE_MASK's Avatar
 
Join Date: Jan 2006
Posts: 9,225
Downloads: 901
Uploads: 73


Default

Quote:
Originally Posted by volodya61 View Post
Thank you TDW

There are three patches for the SHSim.act.. correct?
3 new patches .
THE_MASK is offline   Reply With Quote
Old 03-25-14, 03:30 PM   #3053
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
Looked back over the code for the minimum signal strength adjustment and noticed that I wasn't accounting for 0 based numbers I rewrote those two functions to take into account 0 based numbers and also to clean it up (original code was fugly!) and to add some error checking into it also (to account for user errors - entering wrong values for variables)
There are parts of your code I don't fully get.

Can you please express it in a numerical format (or just as pseudo-code)? If you don't mind, I would like to check your new function in excel, just to make sure that everything is in order now. You are an excellent programmer, but I have the feeling that our math skills are more or less at the same level

Quote:
Originally Posted by tonschk View Post


that's it
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 03-25-14, 04:18 PM   #3054
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by gap View Post
There are parts of your code I don't fully get.

Can you please express it in a numerical format (or just as pseudo-code)?
I read that function just fine and can follow exactly what it's doing

- checks to see if daytime
- if already nighttime then jump to end
- compare current available light (0.35) to start of nighttime value for player's unit (0.5)
- if current available light is greater than or equal to start of nighttime value for player's unit then jump to end
- subtract sunlight value - used to determine if nighttime (0.238) from start of nighttime value (0.5 - gets range) - result is 0.262
- if the result above is negative then jump to end
- subtract sunlight value - used to determine if nighttime (0.238) from current available sunlight (0.35) - result is 0.112
- if the result above is negative then clamp to 0.0
- divides 0.112 by 0.262 - result is 0.4275
- subtract 0.4275 from 1.0 thus getting % of range - result is 0.5725
- get nighttime multiplier (3.0) and add nighttime multiplier addition to it (1.0) - result is 4.0
- subtract 1.0 from 4.0 - this converts to 0 based - result is 3.0
- if the result above is negative then clamp to 0.0
- multiply 0.5725 by 3.0 - result is 1.7175
- add 1.0 to result above thus converting back to 1 based - result is 2.7175
- multiply minimum signal strength (0.1) by 2.7175 - result is 0.27175

0.27175 is new minimum signal strength
TheDarkWraith is offline   Reply With Quote
Old 03-25-14, 04:21 PM   #3055
volodya61
Ocean Warrior
 
volodya61's Avatar
 
Join Date: Feb 2012
Location: Rostov-on-Don, local time GMT+4
Posts: 3,300
Downloads: 374
Uploads: 0


Default

@ TDW

there is new Ru manual for the new version - http://rghost.ru/53354761
__________________
.
Where does human stupidity end?

.


El sueño de la razón produce monstruos © - and for some people awakening will be cruel
volodya61 is offline   Reply With Quote
Old 03-25-14, 04:34 PM   #3056
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
I read that function just fine and can follow exactly what it's doing
I said it beforehand: you are an excellent programmer, and all I know to 'program' (but I suck at it) is my alarm clock

Quote:
Originally Posted by TheDarkWraith View Post
- get nighttime multiplier (3.0) and add nighttime multiplier addition to it (1.0) - result is 4.0
This is exactly what I didn't get before: what is this 'nighttime multiplier addition' that you are talking about?
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 03-25-14, 04:36 PM   #3057
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by gap View Post
This is exactly what I didn't get before: what is this 'nighttime multiplier addition' that you are talking about?
This is a variable in the patch file where the user can define an amount to add to the nighttime multiplier. I have this set to 1.0 for units other than player's unit. Player's unit has a value of 2.5.
TheDarkWraith is offline   Reply With Quote
Old 03-25-14, 06:05 PM   #3058
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
This is a variable in the patch file where the user can define an amount to add to the nighttime multiplier. I have this set to 1.0 for units other than player's unit. Player's unit has a value of 2.5.
I see, good idea!

Is the same constant (night time multiplier addition) applied at night (i.e. when the daytime test fails)? It should

Quote:
Originally Posted by TheDarkWraith View Post
- subtract sunlight value - used to determine if nighttime (0.238) from start of nighttime value (0.5 - gets range) - result is 0.262
...
- subtract sunlight value - used to determine if nighttime (0.238) from current available sunlight (0.35) - result is 0.112
wasn't game's nighttime value equal to 0.283? Was that a mistyping by you, or you have added ways to customize that parameter too?

P.S: well done with your new function
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 03-25-14, 06:28 PM   #3059
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by gap View Post
Is the same constant (night time multiplier addition) applied at night (i.e. when the daytime test fails)? It should

wasn't game's nighttime value equal to 0.283? Was that a mistyping by you, or you have added ways to customize that parameter too?
That's what I forgot That first test at the start of the function to see if it's already nighttime was supposed to be taking care of this. I'll fix it

Yes the game's nighttime value was 0.283. Typo on my part.
I could make this value changeable


Good news! I figured out how to increase the spawn distance from the player's unit The game has a default radius of 40000m (sometimes 35000m) from the player's unit for when other units are rendered. I added some new code and a new variable in the patch file that will allow you to define an additional radius amount I added an additional 40000m to the existing 40000m (80000m total) and sure enough it worked. Any units within a 80000m radius of my unit were being rendered
TheDarkWraith is offline   Reply With Quote
Old 03-25-14, 06:55 PM   #3060
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,214
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by TheDarkWraith View Post
That's what I forgot That first test at the start of the function to see if it's already nighttime was supposed to be taking care of this. I'll fix it


Quote:
Originally Posted by TheDarkWraith View Post
Yes the game's nighttime value was 0.283. Typo on my part.
I could make this value changeable
That would be another useful feature

Quote:
Originally Posted by TheDarkWraith View Post
Good news! I figured out how to increase the spawn distance from the player's unit The game has a default radius of 40000m (sometimes 35000m) from the player's unit for when other units are rendered. I added some new code and a new variable in the patch file that will allow you to define an additional radius amount I added an additional 40000m to the existing 40000m (80000m total) and sure enough it worked. Any units within a 80000m radius of my unit were being rendered
That actually rocks!



Could far away ships be heard through the hydrophone (both for players and for the sonarman)?
Have you noticed any decrease in performance on you high spec system?
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.