Skip to content

Commit ec13bcf

Browse files
committed
Merge branch 'hilnius'
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14638 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2 parents bc46c30 + 33e09e8 commit ec13bcf

File tree

96 files changed

+2664
-552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2664
-552
lines changed

data/gui/karts_online.stkgui

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<stkgui>
2+
3+
<div x="1%" y="1%" width="98%" height="99%" layout="vertical-row" >
4+
5+
<header width="80%"
6+
I18N="In the kart selection (player setup) screen"
7+
text="Choose a Kart"
8+
align="center" text_align="center" />
9+
10+
<placeholder id="playerskarts" width="100%" align="center" proportion="4">
11+
<!-- Contents is added programatically -->
12+
</placeholder>
13+
14+
<spacer height="15" width="25"/>
15+
16+
<box proportion="2" width="100%" layout="vertical-row" padding="2">
17+
<ribbon_grid id="karts" proportion="1" square_items="true" width="100%" align="center"
18+
child_width="90" child_height="90" max_rows="3"/>
19+
</box>
20+
21+
<!-- Groups will be added dynamically at runtime -->
22+
<tabs width="98%" x="1%" height="25" id="kartgroups">
23+
</tabs>
24+
<spacer width="100%" height="2%"/>
25+
</div>
26+
27+
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
28+
29+
</stkgui>

doc/protocols.xls

2.5 KB
Binary file not shown.

sources.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ src/modes/world_with_rank.cpp
157157
src/network/client_network_manager.cpp
158158
src/network/event.cpp
159159
src/network/game_setup.cpp
160-
src/network/http_functions.cpp
161160
src/network/network_interface.cpp
162161
src/network/network_manager.cpp
163162
src/network/network_string.cpp
@@ -183,6 +182,7 @@ src/network/protocols/start_game_protocol.cpp
183182
src/network/protocols/start_server.cpp
184183
src/network/protocols/stop_server.cpp
185184
src/network/protocols/synchronization_protocol.cpp
185+
src/network/race_config.cpp
186186
src/network/server_network_manager.cpp
187187
src/network/stk_host.cpp
188188
src/network/stk_peer.cpp
@@ -480,7 +480,6 @@ src/modes/world_with_rank.hpp
480480
src/network/event.hpp
481481
src/network/client_network_manager.hpp
482482
src/network/game_setup.hpp
483-
src/network/http_functions.hpp
484483
src/network/network_interface.hpp
485484
src/network/network_manager.hpp
486485
src/network/network_string.hpp
@@ -506,6 +505,7 @@ src/network/protocols/start_game_protocol.hpp
506505
src/network/protocols/start_server.hpp
507506
src/network/protocols/stop_server.hpp
508507
src/network/protocols/synchronization_protocol.hpp
508+
src/network/race_config.hpp
509509
src/network/remote_kart_info.hpp
510510
src/network/server_network_manager.hpp
511511
src/network/singleton.hpp

src/config/user_config.cpp

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,162 @@ void GroupUserConfigParam::addChild(UserConfigParam* child)
182182
} // addChild
183183

184184

185+
// ============================================================================
186+
template<typename T>
187+
ListUserConfigParam<T>::ListUserConfigParam(const char* param_name,
188+
const char* comment)
189+
{
190+
m_param_name = param_name;
191+
all_params.push_back(this);
192+
if(comment != NULL) m_comment = comment;
193+
} // ListUserConfigParam
194+
195+
// ============================================================================
196+
template<typename T>
197+
ListUserConfigParam<T>::ListUserConfigParam(const char* param_name,
198+
const char* comment,
199+
int nb_elements,
200+
...)
201+
{
202+
m_param_name = param_name;
203+
all_params.push_back(this);
204+
if(comment != NULL) m_comment = comment;
205+
206+
// add the default list
207+
va_list arguments;
208+
va_start ( arguments, nb_elements );
209+
for ( int i = 0; i < nb_elements; i++ )
210+
m_elements.push_back(va_arg ( arguments, T ));
211+
va_end ( arguments ); // Cleans up the list
212+
} // ListUserConfigParam
213+
214+
// ============================================================================
215+
template<typename T>
216+
ListUserConfigParam<T>::ListUserConfigParam(const char* param_name,
217+
GroupUserConfigParam* group,
218+
const char* comment)
219+
{
220+
m_param_name = param_name;
221+
group->addChild(this);
222+
if(comment != NULL) m_comment = comment;
223+
} // ListUserConfigParam
224+
225+
// ============================================================================
226+
template<typename T>
227+
ListUserConfigParam<T>::ListUserConfigParam(const char* param_name,
228+
GroupUserConfigParam* group,
229+
const char* comment,
230+
int nb_elements,
231+
...)
232+
{
233+
m_param_name = param_name;
234+
group->addChild(this);
235+
if(comment != NULL) m_comment = comment;
236+
237+
// add the default list
238+
va_list arguments;
239+
va_start ( arguments, nb_elements );
240+
for ( int i = 0; i < nb_elements; i++ )
241+
m_elements.push_back(va_arg ( arguments, T ));
242+
va_end ( arguments ); // Cleans up the list
243+
} // ListUserConfigParam
244+
245+
// ----------------------------------------------------------------------------
246+
template<typename T>
247+
void ListUserConfigParam<T>::write(XMLWriter& stream) const
248+
{
249+
const int elts_amount = m_elements.size();
250+
251+
// comment
252+
if(m_comment.size() > 0) stream << " <!-- " << m_comment.c_str();
253+
stream << L" -->\n <" << m_param_name.c_str() << "\n";
254+
255+
stream << L" Size=\"" << elts_amount << "\"\n";
256+
// actual elements
257+
for (int n=0; n<elts_amount; n++)
258+
{
259+
stream << L" " << n << "=\"" << m_elements[n] << "\"\n";
260+
}
261+
stream << L" >\n";
262+
stream << L" </" << m_param_name.c_str() << ">\n\n";
263+
} // write
264+
265+
// ----------------------------------------------------------------------------
266+
267+
// Write your own convert function depending on the type of list you use.
268+
void convert(std::string str, char** str2)
269+
{
270+
*str2 = (char*)(malloc(str.size()+1));
271+
strcpy(*str2, str.c_str());
272+
}
273+
// Write your own equals function depending on the type of list you use.
274+
bool equals(char* str1, char* str2)
275+
{
276+
return (strcmp(str1, str2) == 0);
277+
}
278+
279+
template<typename T>
280+
void ListUserConfigParam<T>::findYourDataInAChildOf(const XMLNode* node)
281+
{
282+
const XMLNode* child = node->getNode( m_param_name );
283+
if (child == NULL)
284+
{
285+
//std::cerr << "/!\\ User Config : Couldn't find parameter group "
286+
// << paramName << std::endl;
287+
return;
288+
}
289+
290+
int attr_count = 0;
291+
child->get( "Size", &attr_count);
292+
for (int n=0; n<attr_count; n++)
293+
{
294+
T elt;
295+
std::ostringstream oss;
296+
oss << n;
297+
std::string str;
298+
child->get( oss.str(), &str);
299+
convert(str, &elt);
300+
// check if the element is already there :
301+
bool there = false;
302+
for (unsigned int i = 0; i < m_elements.size(); i++)
303+
{
304+
if (equals(m_elements[i], elt))
305+
{
306+
there = true;
307+
break;
308+
}
309+
}
310+
if (!there)
311+
{
312+
Log::info("ListUserConfigParam", "New data : %s, \"%s\"", str.c_str(), elt);
313+
m_elements.push_back(elt);
314+
}
315+
}
316+
317+
} // findYourDataInAChildOf
318+
319+
// ----------------------------------------------------------------------------
320+
template<typename T>
321+
void ListUserConfigParam<T>::findYourDataInAnAttributeOf(const XMLNode* node)
322+
{
323+
} // findYourDataInAnAttributeOf
324+
325+
// ----------------------------------------------------------------------------
326+
template<typename T>
327+
void ListUserConfigParam<T>::addElement(T element)
328+
{
329+
m_elements.push_back(element);
330+
} // findYourDataInAnAttributeOf
331+
332+
// ----------------------------------------------------------------------------
333+
template<typename T>
334+
irr::core::stringw ListUserConfigParam<T>::toString() const
335+
{
336+
return "";
337+
} // toString
338+
339+
340+
185341
// ============================================================================
186342
IntUserConfigParam::IntUserConfigParam(int default_value,
187343
const char* param_name,

src/config/user_config.hpp

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,45 @@ class GroupUserConfigParam : public UserConfigParam
9999
irr::core::stringw toString() const;
100100
}; // GroupUserConfigParam
101101

102+
// ============================================================================
103+
template<typename T>
104+
class ListUserConfigParam : public UserConfigParam
105+
{
106+
std::vector<T> m_elements;
107+
108+
public:
109+
ListUserConfigParam(const char* param_name,
110+
const char* comment = NULL);
111+
ListUserConfigParam(const char* param_name,
112+
const char* comment,
113+
int nb_elts,
114+
...);
115+
ListUserConfigParam(const char* param_name,
116+
GroupUserConfigParam* group,
117+
const char* comment = NULL);
118+
ListUserConfigParam(const char* param_name,
119+
GroupUserConfigParam* group,
120+
const char* comment,
121+
int nb_elts,
122+
...);
123+
124+
void write(XMLWriter& stream) const;
125+
void findYourDataInAChildOf(const XMLNode* node);
126+
void findYourDataInAnAttributeOf(const XMLNode* node);
127+
128+
void addElement(T element);
129+
130+
irr::core::stringw toString() const;
131+
132+
operator std::vector<T>() const
133+
{ return m_elements; }
134+
float& operator=(const std::vector<T>& v)
135+
{ m_elements = std::vector<T>(v); return m_elements; }
136+
float& operator=(const ListUserConfigParam& v)
137+
{ m_elements = std::vector<T>(v); return m_elements; }
138+
}; // ListUserConfigParam
139+
typedef ListUserConfigParam<char*> StringListUserConfigParam;
140+
102141
// ============================================================================
103142
class IntUserConfigParam : public UserConfigParam
104143
{
@@ -489,12 +528,44 @@ namespace UserConfigParams
489528
PARAM_PREFIX IntUserConfigParam m_server_port
490529
PARAM_DEFAULT( IntUserConfigParam(7321, "server_port",
491530
"Information about the port to listen on.") );
492-
531+
493532
PARAM_PREFIX IntUserConfigParam m_server_max_players
494533
PARAM_DEFAULT( IntUserConfigParam(16, "server_max_players",
495534
"Maximum number of players on the server.") );
496-
497-
535+
536+
PARAM_PREFIX StringListUserConfigParam m_stun_servers
537+
PARAM_DEFAULT( StringListUserConfigParam("Stun_servers", "The stun servers"
538+
" that will be used to know the public address.",
539+
24,
540+
"provserver.televolution.net",
541+
"sip1.lakedestiny.cordiaip.com",
542+
"stun1.voiceeclipse.net",
543+
"stun01.sipphone.com",
544+
"stun.callwithus.com",
545+
"stun.counterpath.net",
546+
"stun.endigovoip.com",
547+
"stun.ekiga.net",
548+
"stun.ideasip.com" ,
549+
"stun.internetcalls.com",
550+
"stun.ipns.com",
551+
"stun.noc.ams-ix.net",
552+
"stun.phonepower.com",
553+
"stun.phoneserve.com",
554+
"stun.rnktel.com",
555+
"stun.softjoys.com",
556+
"stunserver.org",
557+
"stun.sipgate.net",
558+
"stun.stunprotocol.org",
559+
"stun.voip.aebc.com",
560+
"stun.voipbuster.com",
561+
"stun.voxalot.com",
562+
"stun.voxgratia.org",
563+
"stun.xten.com") );
564+
565+
PARAM_PREFIX StringUserConfigParam m_packets_log_filename
566+
PARAM_DEFAULT( StringUserConfigParam("packets_log.txt", "packets_log_filename",
567+
"Where to log received and sent packets.") );
568+
498569
// ---- Graphic Quality
499570
PARAM_PREFIX GroupUserConfigParam m_graphics_quality
500571
PARAM_DEFAULT( GroupUserConfigParam("GFX",

src/input/wiimote_manager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "input/device_manager.hpp"
2727
#include "input/wiimote.hpp"
2828
#include "utils/string_utils.hpp"
29+
#include "utils/time.hpp"
2930
#include "utils/translation.hpp"
3031

3132
#include "wiiuse.h"
@@ -110,7 +111,7 @@ void WiimoteManager::launchDetection(int timeout)
110111
wiiuse_rumble(wiimote_handle, 1);
111112
}
112113

113-
irr_driver->getDevice()->sleep(200);
114+
StkTime::sleep(200);
114115

115116
for(unsigned int i=0 ; i < m_wiimotes.size(); i++)
116117
{
@@ -284,7 +285,7 @@ void WiimoteManager::threadFunc()
284285
}
285286
}
286287

287-
irr_driver->getDevice()->sleep(1); // 'cause come on, the whole CPU is not ours :)
288+
StkTime::sleep(1); // 'cause come on, the whole CPU is not ours :)
288289
} // end while
289290
} // threadFunc
290291

src/items/item_manager.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include "io/file_manager.hpp"
3030
#include "karts/abstract_kart.hpp"
3131
#include "modes/linear_world.hpp"
32+
#include "network/network_manager.hpp"
33+
#include "network/network_world.hpp"
3234
#include "tracks/quad_graph.hpp"
3335
#include "tracks/track.hpp"
3436
#include "utils/string_utils.hpp"
@@ -309,7 +311,14 @@ void ItemManager::checkItemHit(AbstractKart* kart)
309311
// we pass the kart and the position separately.
310312
if((*i)->hitKart(kart->getXYZ(), kart))
311313
{
312-
collectedItem(*i, kart);
314+
// if we're not playing online, pick the item.
315+
if (!NetworkWorld::getInstance()->isRunning())
316+
collectedItem(*i, kart);
317+
else if (NetworkManager::getInstance()->isServer())
318+
{
319+
collectedItem(*i, kart);
320+
NetworkWorld::getInstance()->collectedItem(*i, kart);
321+
}
313322
} // if hit
314323
} // for m_all_items
315324
} // checkItemHit

src/items/powerup.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,21 @@ void Powerup::hitBonusBox(const Item &item, int add_info)
393393

394394
// Check if two bouncing balls are collected less than getRubberBallTimer()
395395
//seconds apart. If yes, then call getRandomPowerup again. If no, then break.
396-
for(int i=0; i<20; i++)
396+
if (add_info<0)
397397
{
398-
new_powerup = powerup_manager->getRandomPowerup(position, &n);
399-
if(new_powerup != PowerupManager::POWERUP_RUBBERBALL ||
400-
( World::getWorld()->getTime() - powerup_manager->getBallCollectTime()) >
401-
RubberBall::getTimeBetweenRubberBalls() )
402-
break;
398+
for(int i=0; i<20; i++)
399+
{
400+
new_powerup = powerup_manager->getRandomPowerup(position, &n);
401+
if(new_powerup != PowerupManager::POWERUP_RUBBERBALL ||
402+
( World::getWorld()->getTime() - powerup_manager->getBallCollectTime()) >
403+
RubberBall::getTimeBetweenRubberBalls() )
404+
break;
405+
}
406+
}
407+
else // set powerup manually
408+
{
409+
new_powerup = (PowerupManager::PowerupType)((add_info>>4)&0x0f); // highest 4 bits for the type
410+
n = (add_info&0x0f); // last 4 bits for the amount
403411
}
404412

405413
if(new_powerup == PowerupManager::POWERUP_RUBBERBALL)

0 commit comments

Comments
 (0)