- scroll_x = SBX_Left;
- scroll_y = SBY_Upper;
- if (local_player->jx >= SBX_Left + MIDPOSX)
- scroll_x = (local_player->jx <= SBX_Right + MIDPOSX ?
- local_player->jx - MIDPOSX :
- SBX_Right);
- if (local_player->jy >= SBY_Upper + MIDPOSY)
- scroll_y = (local_player->jy <= SBY_Lower + MIDPOSY ?
- local_player->jy - MIDPOSY :
- SBY_Lower);
+ /* if local player not found, look for custom element that might create
+ the player (make some assumptions about the right custom element) */
+ if (!local_player->present)
+ {
+ int start_x = 0, start_y = 0;
+ int found_rating = 0;
+
+ for(y=0; y < lev_fieldy; y++)
+ {
+ for(x=0; x < lev_fieldx; x++)
+ {
+ int element = Feld[x][y];
+
+ if (IS_CUSTOM_ELEMENT(element))
+ {
+ int xx, yy;
+
+ for(yy=0; yy < 3; yy++)
+ {
+ for(xx=0; xx < 3; xx++)
+ {
+ int content;
+ boolean is_player;
+
+ content = element_info[element].content[xx][yy];
+ is_player = (ELEM_IS_PLAYER(content) || content == EL_SP_MURPHY);
+
+ if (is_player && found_rating < 2)
+ {
+ start_x = x + xx - 1;
+ start_y = y + yy - 1;
+
+ found_rating = 2;
+ }
+
+ content = element_info[element].change.content[xx][yy];
+ is_player = (ELEM_IS_PLAYER(content) || content == EL_SP_MURPHY);
+
+ if (is_player && found_rating < 1)
+ {
+ start_x = x + xx - 1;
+ start_y = y + yy - 1;
+
+ found_rating = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ scroll_x = (start_x < SBX_Left + MIDPOSX ? SBX_Left :
+ start_x > SBX_Right + MIDPOSX ? SBX_Right :
+ start_x - MIDPOSX);
+
+ scroll_y = (start_y < SBY_Upper + MIDPOSY ? SBY_Upper :
+ start_y > SBY_Lower + MIDPOSY ? SBY_Lower :
+ start_y - MIDPOSY);
+ }
+ else
+ {
+#if 1
+ scroll_x = (local_player->jx < SBX_Left + MIDPOSX ? SBX_Left :
+ local_player->jx > SBX_Right + MIDPOSX ? SBX_Right :
+ local_player->jx - MIDPOSX);
+
+ scroll_y = (local_player->jy < SBY_Upper + MIDPOSY ? SBY_Upper :
+ local_player->jy > SBY_Lower + MIDPOSY ? SBY_Lower :
+ local_player->jy - MIDPOSY);
+#else
+ scroll_x = SBX_Left;
+ scroll_y = SBY_Upper;
+ if (local_player->jx >= SBX_Left + MIDPOSX)
+ scroll_x = (local_player->jx <= SBX_Right + MIDPOSX ?
+ local_player->jx - MIDPOSX :
+ SBX_Right);
+ if (local_player->jy >= SBY_Upper + MIDPOSY)
+ scroll_y = (local_player->jy <= SBY_Lower + MIDPOSY ?
+ local_player->jy - MIDPOSY :
+ SBY_Lower);
+#endif
+ }