author | erik <erik> | 2007-01-24 23:29:42 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 23:29:42 (UTC) |
commit | 0076a11b467dce1233194ce228287a2a127b1f5d (patch) (unidiff) | |
tree | f2136a1a3e9b5fd6bede52251ed7249365838752 /noncore/games/backgammon | |
parent | 48d9219a96096cf44df8ac24413b36d1b718b1d5 (diff) | |
download | opie-0076a11b467dce1233194ce228287a2a127b1f5d.zip opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.gz opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.bz2 |
Each file in this commit has the issue where it is possible for code to
overrun static buffers. This could lead to serious problems. Granted it
is almost impossible to do that. But it isn't totally impossible. So this
commit makes it impossible to overrun.
-rw-r--r-- | noncore/games/backgammon/moveengine.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp index a4145cc..b102258 100644 --- a/noncore/games/backgammon/moveengine.cpp +++ b/noncore/games/backgammon/moveengine.cpp | |||
@@ -44,25 +44,26 @@ void MoveEngine::position(Pieces& pieces,bool non_qte) | |||
44 | int player1_counter=0; | 44 | int player1_counter=0; |
45 | int player2_counter=0; | 45 | int player2_counter=0; |
46 | 46 | ||
47 | //non qte styles are smaller !! | 47 | //non qte styles are smaller !! |
48 | int offset=(non_qte) ? 5 : 0; | 48 | int offset=(non_qte) ? 5 : 0; |
49 | 49 | ||
50 | for(int a=0;a<28;a++) | 50 | for(int a=0;a<28;a++) |
51 | { | 51 | { |
52 | for(int b=0;b<abs(population[a].total);b++) | 52 | for(int b=0;b<abs(population[a].total);b++) |
53 | { | 53 | { |
54 | if(population[a].total>0) //player 1 pieces | 54 | if(population[a].total>0) //player 1 pieces |
55 | { | 55 | { |
56 | pieces.player1[player1_counter].x=x_coord[a]-offset; | 56 | if (a < 26) |
57 | pieces.player1[player1_counter].x=x_coord[a]-offset; | ||
57 | if(a>=0 && a<13) | 58 | if(a>=0 && a<13) |
58 | { | 59 | { |
59 | pieces.player1[player1_counter].y=yup_coord[b]-offset; | 60 | pieces.player1[player1_counter].y=yup_coord[b]-offset; |
60 | pieces.player1[player1_counter].z=z_coord[b]; | 61 | pieces.player1[player1_counter].z=z_coord[b]; |
61 | pieces.player1[player1_counter].side=false; | 62 | pieces.player1[player1_counter].side=false; |
62 | player1_counter++; | 63 | player1_counter++; |
63 | } | 64 | } |
64 | else if(a>12 && a<26) | 65 | else if(a>12 && a<26) |
65 | { | 66 | { |
66 | pieces.player1[player1_counter].y=ylow_coord[b]-offset; | 67 | pieces.player1[player1_counter].y=ylow_coord[b]-offset; |
67 | pieces.player1[player1_counter].z=z_coord[b]; | 68 | pieces.player1[player1_counter].z=z_coord[b]; |
68 | pieces.player1[player1_counter].side=false; | 69 | pieces.player1[player1_counter].side=false; |
@@ -87,25 +88,26 @@ void MoveEngine::position(Pieces& pieces,bool non_qte) | |||
87 | pieces.player1[player1_counter].x=x_fin1[2]-offset; | 88 | pieces.player1[player1_counter].x=x_fin1[2]-offset; |
88 | pieces.player1[player1_counter].y=y_fin[b-10]-offset; | 89 | pieces.player1[player1_counter].y=y_fin[b-10]-offset; |
89 | pieces.player1[player1_counter].z=z_fin; | 90 | pieces.player1[player1_counter].z=z_fin; |
90 | } | 91 | } |
91 | pieces.player1[player1_counter].side=true; | 92 | pieces.player1[player1_counter].side=true; |
92 | player1_counter++; | 93 | player1_counter++; |
93 | 94 | ||
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
97 | else if(population[a].total<0) //player 2 pieces | 98 | else if(population[a].total<0) //player 2 pieces |
98 | { | 99 | { |
99 | pieces.player2[player2_counter].x=x_coord[a]-offset; | 100 | if (a < 26) |
101 | pieces.player2[player2_counter].x=x_coord[a]-offset; | ||
100 | if(a>=0 && a<13) | 102 | if(a>=0 && a<13) |
101 | { | 103 | { |
102 | pieces.player2[player2_counter].y=yup_coord[b]-offset; | 104 | pieces.player2[player2_counter].y=yup_coord[b]-offset; |
103 | pieces.player2[player2_counter].z=z_coord[b]; | 105 | pieces.player2[player2_counter].z=z_coord[b]; |
104 | pieces.player2[player2_counter].side=false; | 106 | pieces.player2[player2_counter].side=false; |
105 | player2_counter++; | 107 | player2_counter++; |
106 | } | 108 | } |
107 | else if(a>12 && a<26) | 109 | else if(a>12 && a<26) |
108 | { | 110 | { |
109 | pieces.player2[player2_counter].y=ylow_coord[b]-offset; | 111 | pieces.player2[player2_counter].y=ylow_coord[b]-offset; |
110 | pieces.player2[player2_counter].z=z_coord[b]; | 112 | pieces.player2[player2_counter].z=z_coord[b]; |
111 | pieces.player2[player2_counter].side=false; | 113 | pieces.player2[player2_counter].side=false; |