Wow, that's a mouthful of a topic subject!
Here's my problem. I'm changing the skin of an entity. To do so, I get it via bmap_for_entity. That's nice.
However, the thing is: as soon as the entity is visible, the changed skin is overwritten with the original skin's content. So it seems like the skin is loaded only when the entity becomes visible (meaning is in the camera's view frustum) -
regardless of preload_mode and/or ent_preload.
Here's a quick code snippet to try it out. You need an image called "ent.bmp" to run it.
Run it, then press SPACE. A red square (skin AFTER change!) appears in the top left corner. Hit space again and the entity is made visible, and the original skin (your "ent.bmp") appears.
Now, comment the "camera.pan=180;" - line. Now the entity was visible shortly in the view's frustum and it works as expected - the red square changes (the changes are not overwritten). Good.
Now, comment the "wait(2);"-line. Now the entity is created in the view-frustum, but immediatly set invisible. And you have the old behaviour again. You also get that behaviour if its a "wait(1)" instead of a "wait(2)".
Am I misunderstanding ent_preload? I thought the entity skin would then be loaded regardless of the engine's take on its visibility and usefulness of that, but it seems that this is not the case.
void main() {
ENTITY* testent;
level_load(NULL);
preload_mode = 3;
camera.pan=180; //Hello! Comment me out to
testent = ent_create("ent.bmp",vector(100,0,0),NULL);
ent_preload(testent);
wait(2);
set(testent,INVISIBLE);
while(!key_space)wait(1);
while(key_space)wait(1);
bmap_fill(bmap_for_entity(testent,0),COLOR_RED,100);
camera.pan=0;
while(1) {
DEBUG_BMAP(bmap_for_entity(testent,0),1,4);
if(key_space) reset(testent,INVISIBLE); else set(testent,INVISIBLE);
wait(1);
}
}