|
2 registered members (DrissB, clint000),
5,237
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: No level_load for session_open and session_connect
[Re: Tobias]
#373655
06/11/11 18:06
06/11/11 18:06
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
OP
Expert
|
OP
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
I'm not sure I understand your question. "level_load" must be called before creating entities, even if it is a NULL level. So at the beginning of main() I call level_load(NULL), before it's determined whether the game is a client, a server, or just to play offline.
There are no other levels, and no other level_load calls except a level_load(NULL) immediately after joining a game as a client, and immediately after disconnecting as a client, because otherwise I get a "no level!" error.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: No level_load for session_open and session_connect
[Re: jcl]
#374096
06/15/11 14:05
06/15/11 14:05
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
OP
Expert
|
OP
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
I don't want to, but I'm forced to, because if I don't the level gets cleared out and I get this error: Malfunction W1517 on_client_event - no level! ...whenever I (as a client) connect, or leave. AFAIK, level_load (which, when I'm getting these errors, only ever happens in the main function before any sessions are opened or connected) and game_load (which I never use) are the only other functions that clear out a level completely. Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: No level_load for session_open and session_connect
[Re: jcl]
#374110
06/15/11 15:33
06/15/11 15:33
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
OP
Expert
|
OP
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Okay, I'm going to try to be as clear as possible. In the first frame, a level is loaded ("level_load(NULL)"). I can play offline, entities get created all over the place, and I enjoy myself. Then I go back to the main menu (the level still visible in the background), load up the serverlist, and join a game. In an instant, the level disappears, the skybox disappears, and I get this error: Malfunction W1517 on_client_event - no level! Even shorter summary:1. NULL level is loaded. 2. Create entities and interact with them to verify that there is a level. 3. Connect to online game. 4. Error because there is apparently no level when I try to create entities. Optional steps: 5. Read the manual -- "After switching from normal to client mode with a loaded level, the level must be loaded anew." (session_connect) 6. Conclude that the manual's description is enforced by session_connect clearing out the level. 7. Work around the error by loading a NULL level again when a connection is made, and when a connection is lost (which was otherwise also causing the same problem). Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: No level_load for session_open and session_connect
[Re: jcl]
#374123
06/15/11 18:07
06/15/11 18:07
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
OP
Expert
|
OP
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Okay, please help me out here. Below is a self-contained script (no assets required), only about 40 lines long.
// multiplayer test
function startServer() {
session_open("test");
}
function startClient() {
session_connect("test", NULL);
}
function disconnectClient() {
session_close();
}
function createEntity() {
ent_createlocal(SPHERE_MDL, vector(0, random(64) - 32, random(32) - 16), NULL);
}
function main() {
screen_size.x = 200;
screen_size.y = 100;
level_load(NULL);
camera.x -= 100;
ent_createlocal(SPHERE_MDL, nullvector, NULL);
on_s = startServer;
on_c = startClient;
on_d = disconnectClient;
on_e = createEntity;
while (1) {
if (connection & 1) {
draw_text("server", 10, 10, vector(255, 255, 255));
} else if (connection & 2) {
draw_text("client", 10, 10, vector(255, 255, 255));
} else {
draw_text("offline", 10, 10, vector(255, 255, 255));
}
wait(1);
}
}
Please run the script, then press "s" to start a server. Leave that running and run the script again, and press "c" to connect to a server on the same machine. Here it goes black and the entity disappears (level cleared). Press "e" to create a local entity on the client, and I get the error. If I press "e" on the server (or in offline mode), another sphere is created in front of the camera. I'm afraid I don't know why this is going wrong, and any help would be much appreciated. Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: No level_load for session_open and session_connect
[Re: jcl]
#374205
06/16/11 13:04
06/16/11 13:04
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
OP
Expert
|
OP
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Much appreciated  Thanks for your patience. Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
|