~armagetronad-dev/armagetronad/0.4-armagetronad-fortress_ai

« back to all changes in this revision

Viewing changes to src/engine/ePlayer.cpp

  • Committer: Manuel Moos
  • Date: 2010-08-07 21:08:56 UTC
  • mfrom: (2341.1.89 trunk)
  • Revision ID: z-man@users.sf.net-20100807210856-fcyd8v8a36nd9uoq
MergingĀ fromĀ mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
612
612
    // menu entry since the user probably just wants to enter the password.
613
613
    for(int i = 0; i < MAX_PLAYERS; ++i) {
614
614
        tString const &id = se_Players[i].globalID;
615
 
        if(id.Len() <= username.Len() || id(username.Len() - 1) != '@') {
 
615
        if(username.Len() <= 1 || id.Len() <= username.Len() || id(username.Len() - 1) != '@') {
616
616
            continue;
617
617
        }
618
618
        bool match = true;
1125
1125
    nAuthentication::SetLoginResultCallback (&ResultCallback);
1126
1126
#endif
1127
1127
 
 
1128
    lastTooltip_ = -100;
 
1129
 
1128
1130
    nameTeamAfterMe = false;
1129
1131
    favoriteNumberOfPlayersPerTeam = 3;
1130
1132
 
1139
1141
    if ( !getUserName )
1140
1142
        name << "Player " << id+1;
1141
1143
 
 
1144
    // default global ID so logins are redirected to the forums
 
1145
    globalID = "@forums";
 
1146
 
1142
1147
#ifndef DEDICATED
1143
1148
    tString confname;
1144
1149
 
1311
1316
#ifndef DEDICATED
1312
1317
void ePlayer::Render(){
1313
1318
    if (cam) cam->Render();
 
1319
 
 
1320
    // present tooltip help
 
1321
    double now = tSysTimeFloat();
 
1322
    if( se_GameTime() > 1 && now-lastTooltip_ > 1 && !rConsole::CenterDisplayActive() )
 
1323
    {
 
1324
        if( uActionTooltip::Help( ID()+1 ) || uActionTooltip::Help( 0 ) || VetoActiveTooltip(ID()+1) )
 
1325
            lastTooltip_ = now;
 
1326
        else
 
1327
            lastTooltip_ = now+60;
 
1328
    }
1314
1329
}
1315
1330
#endif
1316
1331
 
2076
2091
    return 0;
2077
2092
}
2078
2093
 
 
2094
#ifndef KRAWALL_SERVER
2079
2095
//The Base Remote Admin Password
2080
2096
static tString sg_adminPass( "NONE" );
2081
2097
static tConfItemLine sg_adminPassConf( "ADMIN_PASS", sg_adminPass );
 
2098
#endif
2082
2099
 
2083
2100
#ifdef DEDICATED
2084
2101
 
4256
4273
    return PlayerViewport(p) && PlayerConfig(p);
4257
4274
}
4258
4275
 
 
4276
// veto function for tooltips that require a controllable game object
 
4277
bool ePlayer::VetoActiveTooltip(int player)
 
4278
{
 
4279
    // check if the player exists and controls a living object
 
4280
    if( player == 0 )
 
4281
    {
 
4282
        return true;
 
4283
    }
 
4284
    ePlayer * p = PlayerConfig(player-1);
 
4285
    if ( !p )
 
4286
    {
 
4287
        return true;
 
4288
    }
 
4289
    ePlayerNetID * pn = p->netPlayer;
 
4290
    if ( !pn )
 
4291
    {
 
4292
        return true;
 
4293
    }
 
4294
    eNetGameObject *o = pn->Object();
 
4295
    if (!o || !o->Alive())
 
4296
    {
 
4297
        return true;
 
4298
    }
 
4299
 
 
4300
    return false;
 
4301
}
 
4302
 
4259
4303
static tConfItemBase *vpbtp[MAX_VIEWPORTS];
4260
4304
 
4261
4305
void ePlayer::Init(){
4302
4346
 
4303
4347
uActionPlayer ePlayer::s_chat("CHAT");
4304
4348
 
 
4349
// only display chat in multiplayer games
 
4350
static bool se_ChatTooltipVeto(int)
 
4351
{
 
4352
    return sn_GetNetState() == nSTANDALONE;
 
4353
}
 
4354
 
 
4355
uActionTooltip ePlayer::s_chatTooltip(ePlayer::s_chat, 1, &se_ChatTooltipVeto);
 
4356
uActionTooltip s_toggleSpectatorTooltip(se_toggleSpectator, 1, &se_ChatTooltipVeto);
 
4357
 
4305
4358
int pingCharity = 100;
4306
4359
static const int maxPingCharity = 300;
4307
4360
 
6143
6196
    ResetScoreDifferences();
6144
6197
}
6145
6198
 
6146
 
void ePlayerNetID::DisplayScores(){
 
6199
// flag memorizing whether the scores already have been rendered this frame
 
6200
static bool se_alreadyDisplayedScores = false;
 
6201
 
 
6202
static bool show_scores=false;
 
6203
 
 
6204
void ePlayerNetID::DisplayScores()
 
6205
{
 
6206
    if( !show_scores || !se_mainGameTimer || se_alreadyDisplayedScores )
 
6207
    {
 
6208
        return;
 
6209
    }
 
6210
    se_alreadyDisplayedScores = true;
 
6211
 
6147
6212
    sr_ResetRenderState(true);
6148
6213
 
6149
6214
    REAL W=sr_screenWidth;
7068
7133
}
7069
7134
 
7070
7135
 
7071
 
static bool show_scores=false;
7072
7136
static bool ass=true;
7073
7137
 
7074
7138
void se_AutoShowScores(){
7085
7149
    ass=a;
7086
7150
}
7087
7151
 
7088
 
 
7089
7152
static void scores(){
7090
 
    if (show_scores){
7091
 
        if ( se_mainGameTimer )
7092
 
            ePlayerNetID::DisplayScores();
7093
 
        else
7094
 
            show_scores = false;
7095
 
    }
 
7153
    ePlayerNetID::DisplayScores();
 
7154
    se_alreadyDisplayedScores = false;
7096
7155
}
7097
7156
 
7098
7157
 
7104
7163
 
7105
7164
static rSmallConsoleCallback sc(&force_small_cons);
7106
7165
 
7107
 
static void cd(){
7108
 
    show_scores = false;
7109
 
}
7110
 
 
7111
 
 
 
7166
//static void cd(){
 
7167
//    show_scores = false;
 
7168
//}
 
7169
//static rCenterDisplayCallback c_d(&cd);
7112
7170
 
7113
7171
static uActionGlobal score("SCORE");
7114
7172
 
7121
7179
static uActionGlobalFunc saf(&score,&sf);
7122
7180
 
7123
7181
 
7124
 
static rCenterDisplayCallback c_d(&cd);
7125
 
 
7126
7182
tOutput& operator << (tOutput& o, const ePlayerNetID& p)
7127
7183
{
7128
7184
    tColoredString x;
7160
7216
// *******************
7161
7217
void ePlayerNetID::SetChatting ( ChatFlags flag, bool chatting )
7162
7218
{
 
7219
    /* z-man can't remember why this exception was made; probably
 
7220
       just do disable the chat indicator while you play in local menus.
7163
7221
    if ( sn_GetNetState() == nSTANDALONE && flag == ChatFlags_Menu )
7164
7222
    {
7165
7223
        chatting = false;
7166
7224
    }
 
7225
    */
7167
7226
 
7168
7227
    if ( chatting )
7169
7228
    {