~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to src/render/rViewport.cpp

  • Committer: Luke Dashjr
  • Date: 2009-03-13 04:12:49 UTC
  • mfrom: (563.1.535 armagetronad)
  • mto: This revision was merged to the branch mainline in revision 664.
  • Revision ID: luke+bzr@dashjr.org-20090313041249-zme4k4f6aisbxuz4
mergeĀ fromĀ 0.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
void rViewport::CorrectViewport(int i, int MAX_PLAYERS){
252
252
    if (vpb_dir[i]!=1 && vpb_dir[i]!=-1)
253
253
        vpb_dir[i]=1;
 
254
 
 
255
    int starta=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;
 
256
    int startb=rViewportConfiguration::s_viewportConfigurations[     conf_num]->num_viewports-1;
 
257
    if (starta>startb)
 
258
        startb=starta;
 
259
    
254
260
    s_newViewportBelongsToPlayer[i]+=MAX_PLAYERS-vpb_dir[i];
255
261
    s_newViewportBelongsToPlayer[i]%=MAX_PLAYERS;
 
262
 
 
263
    int oldValue = s_newViewportBelongsToPlayer[i];
 
264
 
256
265
    bool again;
 
266
    bool expectChange = false;
257
267
    do{
 
268
        // rotate player assignemnt
258
269
        s_newViewportBelongsToPlayer[i]+=MAX_PLAYERS+vpb_dir[i];
259
270
        s_newViewportBelongsToPlayer[i]%=MAX_PLAYERS;
 
271
 
 
272
        // check for conflicts
260
273
        again=false;
261
 
        int starta=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;
262
 
        int startb=rViewportConfiguration::s_viewportConfigurations[     conf_num]->num_viewports-1;
263
 
        if (starta>startb)
264
 
            startb=starta;
265
274
        for(int j=starta;j>=0;j--)
266
275
            if (i!=j && s_newViewportBelongsToPlayer[i]
267
276
                    ==s_newViewportBelongsToPlayer[j])
 
277
            {
268
278
                again=true;
 
279
                expectChange=true;
 
280
            }
269
281
    } while(again);
 
282
 
 
283
    if ( oldValue == s_newViewportBelongsToPlayer[i] && expectChange )
 
284
    {
 
285
        // no change? swap players.
 
286
        s_newViewportBelongsToPlayer[i]+=MAX_PLAYERS+vpb_dir[i];
 
287
        s_newViewportBelongsToPlayer[i]%=MAX_PLAYERS;
 
288
 
 
289
        for(int j=starta;j>=0;j--)
 
290
            if (i!=j && s_newViewportBelongsToPlayer[i]
 
291
                    ==s_newViewportBelongsToPlayer[j])
 
292
            {
 
293
                s_newViewportBelongsToPlayer[j] = oldValue;
 
294
            }
 
295
    }
270
296
}
271
297
 
272
298
void rViewport::CorrectViewports(int MAX_PLAYERS){