Assume map compatibility by default if client's map version is 1
[neverball] / ball / st_shared.c
1 /*
2  * Copyright (C) 2003 Robert Kooima - 2006 Jean Privat
3  * Part of the Neverball Project http://icculus.org/neverball/
4  *
5  * NEVERBALL is  free software; you can redistribute  it and/or modify
6  * it under the  terms of the GNU General  Public License as published
7  * by the Free  Software Foundation; either version 2  of the License,
8  * or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
12  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
13  * General Public License for more details.
14  */
15
16 #include "gui.h"
17 #include "config.h"
18 #include "audio.h"
19 #include "state.h"
20
21 #include "game_server.h"
22 #include "game_client.h"
23
24 #include "st_shared.h"
25
26 void shared_leave(int id)
27 {
28     gui_delete(id);
29 }
30
31 void shared_paint(int id, float t)
32 {
33     game_draw(0, t);
34     gui_paint(id);
35 }
36
37 void shared_timer(int id, float dt)
38 {
39     gui_timer(id, dt);
40 }
41
42 int shared_point_basic(int id, int x, int y)
43 {
44     /* Pulse, activate and return the active id (if changed) */
45
46     int jd = gui_point(id, x, y);
47
48     if (jd)
49         gui_pulse(jd, 1.2f);
50
51     return jd;
52 }
53
54 void shared_point(int id, int x, int y, int dx, int dy)
55 {
56     shared_point_basic(id, x, y);
57 }
58
59 int shared_stick_basic(int id, int a, int v)
60 {
61     /* Pulse, activate and return the active id (if changed) */
62
63     int jd = 0;
64
65     if      (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
66         jd = gui_stick(id, v, 0);
67     else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
68         jd = gui_stick(id, 0, v);
69     if (jd)
70         gui_pulse(jd, 1.2f);
71
72     return jd;
73 }
74
75 void shared_stick(int id, int a, int v)
76 {
77     shared_stick_basic(id, a, v);
78 }
79
80 void shared_angle(int id, int x, int z)
81 {
82     game_set_ang(x, z);
83 }
84
85 int shared_click(int b, int d)
86 {
87     if (b == SDL_BUTTON_LEFT && d == 1)
88         return st_buttn(config_get_d(CONFIG_JOYSTICK_BUTTON_A), 1);
89     else
90         return 1;
91 }
92