Merge lp:~mcflypl/vallheru/vallheru into lp:vallheru

Proposed by McFly
Status: Needs review
Proposed branch: lp:~mcflypl/vallheru/vallheru
Merge into: lp:vallheru
Diff against target: 419 lines (+215/-183)
1 file modified
class/player_class.php (+215/-183)
To merge this branch: bzr merge lp:~mcflypl/vallheru/vallheru
Reviewer Review Type Date Requested Status
Bartek Jasicki Needs Fixing
Review via email: mp+123408@code.launchpad.net

This proposal supersedes a proposal from 2012-09-07.

Description of the change

Poprawiłem błąd z kategoriami forum (kolejna niezgodność nazw forumtime w kodzie i forum_time w bazie - będzie trzeba te wszystkie konflikty popoprawiać). Zmieniłem także komentarze na angielskie.

To post a comment you must log in.
Revision history for this message
Bartek Jasicki (thindil) wrote : Posted in a previous version of this proposal

Na razie pojawia się problem z kompatybilnością:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND `cat_id` IN(1,2,3)' at line 1

Błąd dotyczy braku odczytu ustawień dotyczących śledzenia forum (z tego co pamiętam). Plus nie jestem pewien czy ta zmienna dotycząca możliwości edycji jest wymagana. Nie prościej zrobić taką zmienną typu protected (czy jak to tam się nazywa w PHP :) ).

review: Needs Fixing
Revision history for this message
Bartek Jasicki (thindil) wrote :

Znowu wyskakuje gdzieś błąd z zapytaniem do bazy danych. Tym razem już bez konkretnych informacji, obawiam się, że samemu trzeba to przeszukać :(

review: Needs Fixing
Revision history for this message
McFly (mcflypl) wrote :

w jakim miejscu, w jakiej sytuacji?

Revision history for this message
Bartek Jasicki (thindil) wrote :

W dniu 10 września 2012 12:24 użytkownik McFly <email address hidden> napisał:
> w jakim miejscu, w jakiej sytuacji?
> --
> https://code.launchpad.net/~mcflypl/vallheru/vallheru/+merge/123408
> You are reviewing the proposed merge of lp:~mcflypl/vallheru/vallheru into lp:vallheru.

No właśnie nie przyglądałem się temu. Mi to wyskakuje podczas
logowania, dalej nie idzie wszystko. Czyli pewnie znowu coś w pliku
head.php (pewnie jeszcze jakaś zmienna do naprawy). Najlepiej
przeszukać zapytania z die($db->ErrorMsg());

Unmerged revisions

1322. By McFly

rebuild player class

1321. By McFly

Rebuild player class

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'class/player_class.php'
--- class/player_class.php 2012-09-04 09:19:29 +0000
+++ class/player_class.php 2012-09-08 10:15:23 +0000
@@ -6,8 +6,9 @@
6 * @name : player_class.php 6 * @name : player_class.php
7 * @copyright : (C) 2004,2005,2006,2007,2011,2012 Vallheru Team based on Gamers-Fusion ver 2.57 * @copyright : (C) 2004,2005,2006,2007,2011,2012 Vallheru Team based on Gamers-Fusion ver 2.5
8 * @author : thindil <thindil@vallheru.net>8 * @author : thindil <thindil@vallheru.net>
9 * @author : McFly <http://mcfly.com.pl/>
9 * @version : 1.610 * @version : 1.6
10 * @since : 04.09.201211 * @since : 08.09.2012
11 *12 *
12 */13 */
1314
@@ -31,191 +32,222 @@
3132
32class Player 33class Player
33{34{
34 var $user;35 // 'field name' => (editing, type)
35 var $id;36 private $_fields = array(
36 var $level;37 'id' => array(0, 'int'),
37 var $exp;38 'user' => array(1, 'string'),
38 var $hp;39 'email' => array(1, 'string'),
39 var $max_hp;40 'rank' => array(1, 'string'),
40 var $mana;41 'level' => array(1, 'int'),
41 var $energy;42 'exp' => array(1, 'int'),
42 var $max_energy;43 'credits' => array(1, 'int'),
43 var $credits;44 'energy' => array(1, 'int'),
44 var $bank;45 'max_energy' => array(1, 'int'),
45 var $platinum;46 'strength' => array(1, 'int'),
46 var $tribe;47 'agility' => array(1, 'int'),
47 var $rank;48 'ap' => array(1, 'int'),
48 var $location;49 'wins' => array(1, 'int'),
49 var $ap;50 'losses' => array(1, 'int'),
50 var $race;51 'lastkilled' => array(1, 'string'),
51 var $clas;52 'lastkilledby' => array(1, 'string'),
52 var $agility;53 'platinum' => array(1, 'int'),
53 var $strength;54 'age' => array(1, 'int'),
54 var $inteli;55 'logins' => array(1, 'int'),
55 var $pw;56 'hp' => array(1, 'int'),
56 var $wins;57 'max_hp' => array(1, 'int'),
57 var $losses;58 'bank' => array(1, 'int'),
58 var $lastkilled;59 'lpv' => array(1, 'int'),
59 var $lastkilledby;60 'page' => array(1, 'string'),
60 var $age;61 'ip' => array(1, 'string'),
61 var $logins;62 'ability' => array(1, 'int'),
62 var $smith;63 'tribe' => array(1, 'int'),
63 var $attack;64 'profile' => array(1, 'html'),
64 var $miss;65 'refs' => array(1, 'int'),
65 var $magic;66 'corepass' => array(1, 'string'),
66 var $ip;67 'fight' => array(1, 'int'),
67 var $speed;68 'trains' => array(1, 'int'),
68 var $cond;69 'rasa' => array(1, 'string'),
69 var $alchemy;70 'klasa' => array(1, 'string'),
70 var $gg;71 'inteli' => array(1, 'int'),
71 var $avatar;72 'pw' => array(1, 'int'),
72 var $wisdom;73 'atak' => array(1, 'int'),
73 var $shoot;74 'unik' => array(1, 'int'),
74 var $tribe_rank;75 'magia' => array(1, 'int'),
75 var $fletcher;76 'immu' => array(1, 'string'),
76 var $immunited;77 'pm' => array(1, 'int'),
77 var $corepass;78 'miejsce' => array(1, 'string'),
78 var $trains;79 'szyb' => array(1, 'int'),
79 var $fight;80 'wytrz' => array(1, 'int'),
80 var $deity;81 'alchemia' => array(1, 'int'),
81 var $maps;82 'gg' => array(1, 'string'),
82 var $rest;83 'avatar' => array(1, 'string'),
83 var $page;84 'wisdom' => array(1, 'int'),
84 var $profile;85 'shoot' => array(1, 'int'),
85 var $crime;86 'tribe_rank' => array(1, 'string'),
86 var $gender;87 'fletcher' => array(1, 'int'),
87 var $leadership;88 'deity' => array(1, 'string'),
88 var $antidote;89 'maps' => array(1, 'int'),
89 var $breeding;90 'rest' => array(1, 'string'),
90 var $poll;91 'crime' => array(1, 'int'),
91 var $mining;92 'gender' => array(1, 'string'),
92 var $lumberjack;93 'bridge' => array(1, 'string'),
93 var $herbalist;94 'temp' => array(1, 'int'),
94 var $jeweller;95 'leadership' => array(1, 'int'),
95 var $vallars;96 'forum_time' => array(1, 'int'),
96 var $newbie;97 'tforum_time' => array(1, 'int'),
97 var $thievery;98 'bless' => array(1, 'string'),
98 var $perception;99 'blessval' => array(1, 'int'),
99 var $forumtime;100 'antidote' => array(1, 'string'),
100 var $tforumtime;101 'freeze' => array(1, 'int'),
101 var $metallurgy;102 'breeding' => array(1, 'int'),
102 var $revent;103 'houserest' => array(1, 'string'),
103 var $room;104 'poll' => array(1, 'string'),
104 var $oldstats;105 'mining' => array(1, 'int'),
105 var $settings;106 'lumberjack' => array(1, 'int'),
106 var $changed;107 'herbalist' => array(1, 'int'),
107 var $chattimes;108 'astralcrime' => array(1, 'string'),
108 /**109 'changedeity' => array(1, 'int'),
109 * Player equipment110 'jeweller' => array(1, 'int'),
110 */111 'vallars' => array(1, 'int'),
111 var $equip;112 'metallurgy' => array(1, 'int'),
112/**113 'newbie' => array(1, 'int'),
113* Class constructor - get data from database and write it to variables114 'thievery' => array(1, 'int'),
114*/115 'perception' => array(1, 'int'),
115 function Player($pid) 116 'roleplay' => array(1, 'string'),
116 {117 'ooc' => array(1, 'string'),
118 'shortrpg' => array(1, 'string'),
119 'room' => array(1, 'string'),
120 'chattimes' => array(1, 'int'),
121 'settings' => array(1, 'string')
122 );
123
124 /**
125 * Class constructor - get data from database and write it to variables
126 *
127 * @param int $pid Player ID
128 * @param array $fields Fields to get
129 */
130 public function __construct($pid, $fields=array()) {
117 global $db;131 global $db;
118 $pid = intval($pid);132
119 $stats = $db -> Execute("SELECT * FROM `players` WHERE `id`=".$pid);133 $arrFields = (is_array($fields) && !empty($fields)) ? $fields : $this->_fields;
120 if ($stats -> fields['id'] != $pid) 134 $strFields = '';
121 {135 foreach ($arrFields as $field => $value) {
122 return FALSE;136 $strFields .= $field.', ';
123 }137 }
124 $this -> user = $stats -> fields['user'];138 if (empty($strFields))
125 $this -> id = $stats -> fields['id'];139 return false;
126 $this -> level = $stats -> fields['level'];140 $strFields = substr($strFields,0,-2); //delete last comma
127 $this -> exp = $stats -> fields['exp'];141
128 $this -> hp = $stats -> fields['hp'];142 $pid = intval($pid);
129 $this -> max_hp = $stats -> fields['max_hp'];143 $stats = $db->Execute('SELECT '.$strFields.' FROM `players` WHERE `id`='.$pid) or die($db->ErrorMsg());
130 $this -> mana = $stats -> fields['pm'];144 if (empty($stats->fields))
131 $this -> energy = $stats -> fields['energy'];145 return false;
132 $this -> max_energy = $stats -> fields['max_energy'];146
133 $this -> credits = $stats -> fields['credits'];147 foreach ($stats->fields as $field => $value) {
134 $this -> bank = $stats -> fields['bank'];148 switch ($this->_fields[$field][1]) {
135 $this -> platinum = $stats -> fields['platinum'];149 case 'int':
136 $this -> tribe = $stats -> fields['tribe'];150 $this->$field = (float)$value;
137 $this -> rank = $stats -> fields['rank'];151 break;
138 $this -> location = $stats -> fields['miejsce'];152 case 'string':
139 $this -> ap = $stats -> fields['ap'];153 $this->$field = $value;
140 $this -> race = $stats -> fields['rasa'];154 break;
141 $this -> clas = $stats -> fields['klasa'];155 case 'html':
142 $this -> agility = $stats -> fields['agility'];156 $this->$field = $value;
143 $this -> strength = $stats -> fields['strength'];157 break;
144 $this -> inteli = $stats -> fields['inteli'];158 case 'json':
145 $this -> pw = $stats -> fields['pw'];159 $this->$field = json_decode($value);
146 $this -> wins = $stats -> fields['wins'];160 break;
147 $this -> losses = $stats -> fields['losses'];161 }
148 $this -> lastkilled = $stats -> fields['lastkilled'];162 }
149 $this -> lastkilledby = $stats -> fields['lastkilledby'];163 $stats->Close();
150 $this -> age = $stats -> fields['age'];164
151 $this -> logins = $stats -> fields['logins'];165 /**
152 $this -> smith = $stats -> fields['ability'];166 * Compatibility
153 $this -> attack = $stats -> fields['atak'];167 */
154 $this -> miss = $stats -> fields['unik'];168 $this->mana = $this->pm;
155 $this -> magic = $stats -> fields['magia'];169 $this->location = $this->miejsce;
156 $this -> ip = $stats -> fields['ip'];170 $this->race = $this->rasa;
157 $this -> speed = $stats -> fields['szyb'];171 $this->clas = $this->klasa;
158 $this -> cond = $stats -> fields['wytrz'];172 $this->smith = $this->ability;
159 $this -> alchemy = $stats -> fields['alchemia'];173 $this->miss = $this->unik;
160 $this -> gg = $stats -> fields['gg'];174 $this->magic = $this->magia;
161 $this -> avatar = $stats -> fields['avatar'];175 $this->speed = $this->szyb;
162 $this -> wisdom = $stats -> fields['wisdom'];176 $this->cond = $this->wytrz;
163 $this -> shoot = $stats -> fields['shoot'];177 $this->alchemy = $this->alchemia;
164 $this -> tribe_rank = $stats -> fields['tribe_rank'];178 $this->immunited = $this->immu;
165 $this -> fletcher = $stats -> fields['fletcher'];179 $this->antidote = (!empty($this->antidote)) ? $this->antidote{0} : NULL;
166 $this -> immunited = $stats -> fields['immu'];180 $this->oldstats = array($this->agility, $this->strength, $this->inteli, $this->wisdom, $this->speed, $this->cond);
167 $this -> corepass = $stats -> fields['corepass'];181 $this->settings = $this->toarray($stats->fields['settings']);
168 $this -> trains = $stats -> fields['trains'];182 $this->forumtime = $this->forum_time;
169 $this -> fight = $stats -> fields['fight'];183
170 $this -> deity = $stats -> fields['deity'];184 $objRevent = $db->Execute('SELECT `state` FROM `revent` WHERE `pid`='.$pid);
171 $this -> maps = $stats -> fields['maps'];185 $this->revent = ($objRevent->fields['state']) ? $objRevent->fields['state'] : 0;
172 $this -> rest = $stats -> fields['rest'];186 $objRevent->Close();
173 $this -> page = $stats -> fields['page'];187
174 $this -> profile = $stats -> fields['profile'];188 /**
175 $this -> crime = $stats -> fields['crime'];189 * Player equipment
176 $this -> gender = $stats -> fields['gender'];190 */
177 $this -> leadership = $stats -> fields['leadership'];191 $this->equip = $this->equipment();
178 if (!empty($stats -> fields['antidote']))192
179 {193 $this->curstats();
180 $this -> antidote = $stats -> fields['antidote']{0};
181 }
182 else
183 {
184 $this -> antidote = '';
185 }
186 $this -> breeding = $stats -> fields['breeding'];
187 $this -> poll = $stats -> fields['poll'];
188 $this -> mining = $stats -> fields['mining'];
189 $this -> lumberjack = $stats -> fields['lumberjack'];
190 $this -> herbalist = $stats -> fields['herbalist'];
191 $this -> jeweller = $stats -> fields['jeweller'];
192 $this->vallars = $stats->fields['vallars'];
193 $this->newbie = $stats->fields['newbie'];
194 $this->thievery = $stats->fields['thievery'];
195 $this->perception = $stats->fields['perception'];
196 $this->forumtime = $stats->fields['forum_time'];
197 $this->tforumtime = $stats->fields['tforum_time'];
198 $this->metallurgy = $stats->fields['metallurgy'];
199 $stats -> Close();
200 $objRevent = $db->Execute("SELECT `state` FROM `revent` WHERE `pid`=".$pid);
201 if (!$objRevent->fields['state'])
202 {
203 $this->revent = 0;
204 }
205 else
206 {
207 $this->revent = $objRevent->fields['state'];
208 }
209 $objRevent->Close();
210 $this->room = $stats->fields['room'];
211 $this->chattimes = $stats->fields['chattimes'];
212 $this->oldstats = array($this->agility, $this->strength, $this->inteli, $this->wisdom, $this->speed, $this->cond);
213 $this->settings = $this->toarray($stats->fields['settings']);
214 $this->equip = $this->equipment();
215 $this->curstats();
216 }194 }
195
196 /**
197 * Method to update fields in database
198 *
199 * @param array $fields
200 * @param int $pid
201 * @return bool
202 */
203 public function Update($fields, $pid=NULL)
204 {
205 global $db;
206
207 if (!is_array($fields))
208 return false;
209 $pid = (!empty($pid)) ? (int)$pid : $this->id;
210
211 $strUpdate = '';
212 $i = 0;
213 foreach ($fields as $field => $value)
214 {
215 if (isset($this->_fields[$field]) && $this->_fields[$field][0]) {
216 switch ($this->_fields[$field][1])
217 {
218 case 'int':
219 $value = (int)$value;
220 $strUpdate .= '`'.$field.'`='.$value.', ';
221 break;
222 case 'string':
223 $value = htmlspecialchars($value);
224 $strUpdate .= '`'.$field.'`=\''.$value.'\', ';
225 break;
226 case 'html':
227 $value = addslashes($value);
228 $strUpdate .= '`'.$field.'`=\''.$value.'\', ';
229 break;
230 case 'json':
231 $value = json_encode($value);
232 $strUpdate .= '`'.$field.'`=\''.$value.'\', ';
233 break;
234 }
235 $this->$field = $value;
236 $i++;
237 }
238 }
239 if (!empty($strUpdate))
240 {
241 $strUpdate = substr($strUpdate,0,-2); //usuwa ostatni przecinek
242 $db->Execute('UPDATE `players` SET '.$strUpdate.' WHERE `id`='.$pid) or die($db->ErrorMsg());
243
244 return true;
245 }
246 else
247 return false;
248 }
217249
218 /**250 /**
219 * Function convert string value to array251 * Function convert string value to array
220 */252 */
221 function toarray($strValue)253 function toarray($strValue)

Subscribers

People subscribed via source and target branches

to status/vote changes: