About week ago I decided to make an attept to create multiplayer rpg game in j2me. The game needs server so I use c and mingw32 as compiler. I thought the biggest problem will be network programming as I never tried that before. But the j2me client is connecting nicely I have managed to get multiple connections (sending/recieving data) from the clients to the server. Now i encoutered very strange problem of other kind :|. Maybe i'll paste some declarations:
Code:
[...]
const int D_SOCKETS = 16;
[...]
int main(int argc, char **argv) {
[...]
int player_y[65536];
int bytes_sent[D_SOCKETS];
> then all of the uses of that variables in the file:
Code:
player_y[sockets[index]]=rip_y(buffer);
tymczasowa = ((player_y[sockets[i]])/128);
buffer2[6]= 128+tymczasowa;
buffer2[7]= 128+(player_y[sockets[i]])-tymczasowa*128;
for (i=0;i<65536;i++) bytes_sent[i]=0;
bytes_sent[(sockets[index])]++;
for (j=0;j<sockets_index;j++) {
if(sockets[j]!=sockets[index]) {
[...]
bytes_sent[(sockets[j])] += 22;
} }
bytes_sent[(sockets[index])]=0;
so as can you see this values are non related in any way. But each time
bytes_sent[(sockets[j])] += 22;
is executed value of player_y[(sockets[2])]) changes the same way...
exacly bytes_sent[728] = socket_y[712]...
Eeah time I change one the other changes to the same value..
It has some really big arrays so i had to change the stack size to 30mb. I compile it with command:
g++ -Wl,--stack=31457280 sock.c -o main.exe -lwsock32
I use libraries:
Code:
#include <stdio.h>
#include <time.h>
#include <Winsock2.h>
#else
#define closesocket close
#endif
I know its only one case if I change some minor things it will dissapear but im sure there is more of these mixups. Its just one that I run into. Please help. I have no idea what to do to fix this permanently. I can email the whole code if it is necessary.
screenshots from the engine:
mmorpg.jpg