FloooD / custom_cs2dsrv

Jermuk's custom Counter Strike 2D Server written in C and modified by FloooD and leegao.
173.192.35.85:36000
3 stars 0 forks source link

extern sock? #33

Open FloooD opened 13 years ago

FloooD commented 13 years ago

would there be anything wrong in making the sock in main.c an extern?

since for quite a few functions the first argument is ALWAYS sock... so might as well just take out that argument :P

leegao commented 13 years ago

meh, k I guess

FloooD commented 13 years ago

hm would needa rename some stuff in cross_layer

btw it's mostly to move lines from main to onsecond and onframe

FloooD commented 13 years ago

k done

btw on many maps, when i try to join

* glibc detected * ./custom_cs2dsrv: free(): invalid pointer: 0x0805f406 *** fuuuuuuuuuuu

leegao commented 13 years ago

which maps? Gonna squeeze a debug session in before midterm time rolls around again

FloooD commented 13 years ago

basically anything that is not de_cs2d has a pretty high chance of crashing it

aim_fr33kz is one of them...

leegao commented 13 years ago

o_O can you send me aim_fr33kz? Just delete all of the free() calls in map.c

FloooD commented 13 years ago

http://flame2d.tk/aim_fr33kz.map

leegao commented 13 years ago

o_O I can't replicate the segfault, are you using make or make --no-shared?

leegao commented 13 years ago

Whoa, this new issues system is pretty

leegao commented 13 years ago

oh nvm, when you join

leegao commented 13 years ago

Sighz, I hate malloc so much

The problem comes from packet.c:line 1024 if (!i) return (byte*)"";

Where "" is a const char* allocated OFF of the heap. So calling free off of the heap segfaults <_<. It'll be patched in a jiffy

leegao commented 13 years ago

nvm, a second segfault occurs with aim_fr33kz on lua_hooks, not the case with de_cs2d though o_O

FloooD commented 13 years ago

lol this looks like the pull request thing now :P

ya sometimes it segfaults at startup sometimes when u try to join

FloooD commented 13 years ago
int check_sendqueue(void){ // returns the number of elements sent
    int threshold = 0x30, i = 0, cur = mtime(); // 48 sends per iteration

why 48?

leegao commented 13 years ago

just a random number. I figured that it had to be greater than 32, but not too great so that it retains a maximum processing time per iteration (to prevent the server from getting flooded during one iteration)

FloooD commented 13 years ago

worst case scenario: 32 players in server all moving

server receives 32 packets every 20 ms for every packet received, ~32 are sent out... so around 1000 packets every 20 ms... 100 packets every 2 ms i.e. 1 frame at 500fps

well i guess it doesn't really matter for now ;p