ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.66k stars 616 forks source link

Prevent server/client from sending/requesting same file twice. #1345

Open R4to0 opened 11 years ago

R4to0 commented 11 years ago

Hello! I don't know if this is considered a feature request or a bug, but here we go! This affects all GoldSrc Engine mods and games. No metamod/amxx have been used while testing this. My english is limited, you may see typos.


Intro:

When we start a map, the server/client precaches all needed files to send to client reading from resource file (mapname.res), and if we don't have the res file, server precache itself some files and tries to send to client: models, sprites and sounds (not all of them, miss t.mdl 01.mdl and some spr, making client crashes, needs to be mentioned in a res file).


The problem:

With resource file correctly generated (using resgen or by hand) and all file dependencies mentioned in it, the server keeps sending some files twice or more, making the client request a file that has been downloaded in same session, wasting bandwidth and slowing download!


Test environment:

Server side (home made): Window Server 2003 x86 up to date; 2GB DDR2 667MHz; 30mbit download speed, 7mbit upload speed; HLDS for Half-Life DM build 6132 IP: 187.22.113.208:27019 Password: testing

Client side: Windows 8 Pro 64-bit up to date; 4GB DDR2 800MHz; 10mbit download speed; Half-Life build 6153


Reproducing:

I'll use a map called persia for this.

Map structure: http://pastebin.com/fyTCbf47

We have 48 files excluding .res file!

Let's try without .res file first and see which files server tries to send to client: http://pastebin.com/73PtWEu8

9 of 48 files have been sent by hlds to client.

Let's try with .res file in maps folder: http://pastebin.com/7MSjYpsn

Now we have requested 58 files from server! But we only have 48 files for this map!


Conclusion and benefits:


I think that is all. I hope anyone can understand...

Thanks, Rafael "R4to0" Maciel.

alfred-valve commented 11 years ago

Can you post the map and its resources as a download link here please so we can test this locally.

R4to0 commented 11 years ago

2 good maps for testing: http://fastdl.hldm-br.net/persia.zip http://fastdl.hldm-br.net/ag_crossfirexM.zip

I can't provide a test server atm, router hardware failure (solving asap).

di57inct commented 11 years ago

I can confirm this issue. Happened to me lots of times. Same file downloaded twice.