Subversion Repositories Games.Carmageddon

Rev

Rev 18 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 20
Line 162... Line 162...
162
    harness_game_config.enable_diagnostics = 0;
162
    harness_game_config.enable_diagnostics = 0;
163
    // no volume multiplier
163
    // no volume multiplier
164
    harness_game_config.volume_multiplier = 1.0f;
164
    harness_game_config.volume_multiplier = 1.0f;
165
    // start window in windowed mode
165
    // start window in windowed mode
166
    harness_game_config.start_full_screen = 0;
166
    harness_game_config.start_full_screen = 0;
167
    // Disable gore check emulation
167
    // Emulate gore check
168
    harness_game_config.gore_check = 0;
168
    harness_game_config.gore_check = 0;
169
    // Enable Sound Options menu
169
    // Enable Sound Options menu
170
    harness_game_config.sound_options = 1; // Pierre-Marie Baty -- invert option default value
170
    harness_game_config.sound_options = 1; // Pierre-Marie Baty -- invert option default value
171
    // Skip binding socket to allow local network testing
171
    // Skip binding socket to allow local network testing
172
    harness_game_config.no_bind = 0;
172
    harness_game_config.no_bind = 0;
173
    // Disable verbose logging
-
 
174
    harness_game_config.verbose = 0;
-
 
175
 
173
 
176
    // install signal handler by default
174
    // install signal handler by default
177
    harness_game_config.install_signalhandler = 1;
175
    harness_game_config.install_signalhandler = 1;
178
 
176
 
179
    Harness_ProcessCommandLine(argc, argv);
177
    Harness_ProcessCommandLine(argc, argv);
Line 217... Line 215...
217
        }
215
        }
218
#endif /* __APPLE__ */
216
#endif /* __APPLE__ */
219
        if (root_dir[0] == 0)
217
        if (root_dir[0] == 0)
220
            strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check
218
            strcpy(root_dir, "."); // Pierre-Marie Baty -- consistency check
221
    }
219
    }
222
        printf("Using root directory: %s\n", root_dir);
220
    printf("Using root directory: %s\n", root_dir);
223
        result = chdir(root_dir);
221
    result = chdir(root_dir);
224
        if (result != 0) {
222
    if (result != 0) {
225
            LOG_PANIC("Failed to chdir. Error is %s", strerror(errno));
223
        LOG_PANIC("Failed to chdir. Error is %s", strerror(errno));
226
    }
224
    }
227
 
225
 
228
    if (harness_game_info.mode == eGame_none) {
226
    if (harness_game_info.mode == eGame_none) {
229
        Harness_DetectGameMode();
227
        Harness_DetectGameMode();
230
    }
228
    }
Line 253... Line 251...
253
            harness_debug_level = atoi(s + 1);
251
            harness_debug_level = atoi(s + 1);
254
            LOG_INFO("debug level set to %d", harness_debug_level);
252
            LOG_INFO("debug level set to %d", harness_debug_level);
255
            handled = 1;
253
            handled = 1;
256
        } else if (strstr(argv[i], "--physics-step-time=") != NULL) {
254
        } else if (strstr(argv[i], "--physics-step-time=") != NULL) {
257
            char* s = strstr(argv[i], "=");
255
            char* s = strstr(argv[i], "=");
258
            harness_game_config.physics_step_time = atoi(s + 1);
256
            harness_game_config.physics_step_time = atof(s + 1);
259
            LOG_INFO("Physics step time set to %d", harness_game_config.physics_step_time);
257
            LOG_INFO("Physics step time set to %f", harness_game_config.physics_step_time);
260
            handled = 1;
258
            handled = 1;
261
        } else if (strstr(argv[i], "--fps=") != NULL) {
259
        } else if (strstr(argv[i], "--fps=") != NULL) {
262
            char* s = strstr(argv[i], "=");
260
            char* s = strstr(argv[i], "=");
263
            harness_game_config.fps = atoi(s + 1);
261
            harness_game_config.fps = atoi(s + 1);
264
            LOG_INFO("FPS limiter set to %f", harness_game_config.fps);
262
            LOG_INFO("FPS limiter set to %f", harness_game_config.fps);
Line 310... Line 308...
310
            i--;
308
            i--;
311
        }
309
        }
312
    }
310
    }
313
 
311
 
314
    return 0;
312
    return 0;
-
 
313
}
-
 
314
 
-
 
315
// Render 2d back buffer
-
 
316
void Harness_RenderScreen(br_pixelmap* dst, br_pixelmap* src) {
-
 
317
    gHarness_platform.Renderer_FullScreenQuad((uint8_t*)src->pixels);
-
 
318
 
-
 
319
    last_dst = dst;
-
 
320
    last_src = src;
-
 
321
}
-
 
322
 
-
 
323
void Harness_Hook_BrV1dbRendererBegin(br_v1db_state* v1db) {
-
 
324
    renderer_state = NewHarnessBrRenderer();
-
 
325
    v1db->renderer = (br_renderer*)renderer_state;
-
 
326
}
-
 
327
 
-
 
328
static int Harness_CalculateFrameDelay(void) {
-
 
329
    if (harness_game_config.fps == 0) {
-
 
330
        return 0;
-
 
331
    }
-
 
332
 
-
 
333
    unsigned int now = GetTotalTime();
-
 
334
 
-
 
335
    if (last_frame_time != 0) {
-
 
336
        unsigned int frame_time = now - last_frame_time;
-
 
337
        last_frame_time = now;
-
 
338
        if (frame_time < 100) {
-
 
339
            int sleep_time = (1000 / harness_game_config.fps) - frame_time;
-
 
340
            if (sleep_time > 5) {
-
 
341
                return sleep_time;
-
 
342
            }
-
 
343
        }
-
 
344
    }
-
 
345
    return 0;
-
 
346
}
-
 
347
 
-
 
348
void Harness_Hook_renderActor(br_actor* actor, br_model* model, br_material* material, br_token type) {
-
 
349
    gHarness_platform.Renderer_Model(actor, model, material, type, renderer_state->state.matrix.model_to_view);
-
 
350
}
-
 
351
 
-
 
352
// Called by game to swap buffers at end of frame rendering
-
 
353
void Harness_Hook_BrPixelmapDoubleBuffer(br_pixelmap* dst, br_pixelmap* src) {
-
 
354
 
-
 
355
    // draw the current colour_buffer (2d screen) contents
-
 
356
    Harness_RenderScreen(dst, src);
-
 
357
 
-
 
358
    int delay_ms = Harness_CalculateFrameDelay();
-
 
359
    gHarness_platform.SwapWindow();
-
 
360
    if (delay_ms > 0) {
-
 
361
        gHarness_platform.Sleep(delay_ms);
-
 
362
    }
-
 
363
 
-
 
364
    gHarness_platform.Renderer_ClearBuffers();
-
 
365
    last_frame_time = GetTotalTime();
-
 
366
}
-
 
367
 
-
 
368
void Harness_RenderLastScreen(void) {
-
 
369
    if (last_dst) {
-
 
370
        Harness_RenderScreen(last_dst, last_src);
-
 
371
        gHarness_platform.SwapWindow();
-
 
372
    }
315
}
373
}
316
 
374
 
317
// Filesystem hooks
375
// Filesystem hooks
318
FILE* Harness_Hook_fopen(const char* pathname, const char* mode) {
376
FILE* Harness_Hook_fopen(const char* pathname, const char* mode) {
319
    return OS_fopen(pathname, mode);
377
    return OS_fopen(pathname, mode);