-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrole.jsp
1442 lines (1334 loc) · 59.5 KB
/
role.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<%@page import="java.sql.*"%>
<%@page import="protocol.*"%>
<%@page import="java.io.*"%>
<%@page import="java.text.*"%>
<%@page import="java.util.*"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.goldhuman.Common.Octets"%>
<%@page import="com.goldhuman.IO.Protocol.Rpc.Data.DataVector"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@include file="WEB-INF/.pwadminconf.jsp"%>
<div align="left" id="sqltip" style="background: #ffffff; border: 1px solid #000000; white-space: nowrap; visibility: hidden; padding: 5px; position: absolute;">
<b><u>Synchronize GameDB with MySQL Role Table</u></b><br>
<b>● </b>Make sure Perfect World Server is running<br>
<b>● </b>Make sure maps are stopped (inconsistence & lag)<br>
<b>● </b>Process may take a while depending on role amount
</div>
<script type="text/javascript">
function move_tip(id, event)
{
document.getElementById(id).style.left = event.clientX -5 + document.body.scrollLeft;
document.getElementById(id).style.top = event.clientY + 25 + document.body.scrollTop;
}
function show_tip(id)
{
document.getElementById(id).style.visibility = "visible";
}
function hide_tip(id)
{
document.getElementById(id).style.visibility = "hidden";
}
function select_item(itemname, itemgroup, itemindex, itemid, itemguid1, itemguid2, itemmask, itemproctype, itempos, itemcount, itemcountmax, itemexpire, itemdata)
{
document.getElementById("itemname").href = "http://www.pwdatabase.com/items/" + itemid;
document.getElementById("itemname").innerHTML = itemname;
if(itemgroup == "equipment")
{
document.update.itemgroup[0].selected = "1";
}
if(itemgroup == "inventory")
{
document.update.itemgroup[1].selected = "1";
}
if(itemgroup == "storage")
{
document.update.itemgroup[2].selected = "1";
}
document.update.itemindex.value = itemindex;
document.update.itemid.value = itemid;
document.update.itemguid1.value = itemguid1;
document.update.itemguid2.value = itemguid2;
document.update.itemmask.value = itemmask;
document.update.itemproctype.value = itemproctype;
document.update.itempos.value = itempos;
document.update.itemcount.value = itemcount;
document.update.itemcountmax.value = itemcountmax;
document.update.itemexpire.value = itemexpire;
document.update.itemdata.value = itemdata;
}
</script>
<%!
HashMap<Integer, Object[]> loadFactions(String path)
{
HashMap<Integer, Object[]> factions = new HashMap<Integer, Object[]>();
try
{
String command = path + "gamedbd/gamedbd " + path + "gamedbd/gamesys.conf listfaction";
File working_directory = new File(path + "gamedbd/");
Process p = Runtime.getRuntime().exec(command, null, working_directory);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
String[] values;
// skip header line
input.readLine();
while((line = input.readLine()) != null)
{
values = line.split(",");
factions.put(Integer.parseInt(values[0]), new Object[]{values[1], Integer.parseInt(values[2]), Integer.parseInt(values[5])});
}
}
catch(Exception e)
{
// error loading factions
}
return factions;
}
%>
<%!
HashMap<Integer, Integer[]> loadFactionMembers(String path)
{
HashMap<Integer, Integer[]> members = new HashMap<Integer, Integer[]>();
try
{
String command = path + "gamedbd/gamedbd " + path + "gamedbd/gamesys.conf listfactionuser";
File working_directory = new File(path + "gamedbd/");
Process p = Runtime.getRuntime().exec(command, null, working_directory);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
String[] values;
// skip header line
input.readLine();
while((line = input.readLine()) != null)
{
values = line.split(",");
members.put(Integer.parseInt(values[0]), new Integer[]{Integer.parseInt(values[2]), Integer.parseInt(values[4])});
}
}
catch(Exception e)
{
// error loading members
}
return members;
}
%>
<%!
HashMap<Integer, String> loadFactionDomains(String path)
{
HashMap<Integer, String> domains = new HashMap<Integer, String>();
try
{
String command = path + "gamedbd/gamedbd " + path + "gamedbd/gamesys.conf listcity";
File working_directory = new File(path + "gamedbd/");
Process p = Runtime.getRuntime().exec(command, null, working_directory);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
String[] values;
// skip header line
Integer faction;
input.readLine();
while((line = input.readLine()) != null)
{
values = line.split(",");
faction = Integer.parseInt(values[2]);
if(faction > 0)
{
if(domains.containsKey(faction))
{
domains.put(faction, domains.get(faction) + ";" + values[0]);
}
else
{
domains.put(faction, values[0]);
}
}
}
}
catch(Exception e)
{
// error loading domains
}
return domains;
}
%>
<%!
HashMap<Integer, Integer[]> loadPvP(String logfile)
{
HashMap<Integer, Integer[]> pvp_table = new HashMap<Integer, Integer[]>();
try
{
String line;
int victim;
int attacker;
Integer[] pvp_entry;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(logfile)));
while((line = br.readLine()) != null)
{
if(line.indexOf(":die:") > -1 && line.indexOf("type=2") > -1) // i.e. "type=258" -> killed by player, "type=4" -> killed by mob
{
victim = Integer.parseInt(line.substring(line.indexOf("roleid=")+7, line.indexOf(":type=")));
attacker = Integer.parseInt(line.substring(line.indexOf("attacker=")+9));
if(pvp_table.containsKey(victim))
{
pvp_entry = pvp_table.get(victim);
pvp_entry[1]++;
pvp_table.put(victim, pvp_entry);
}
else
{
pvp_table.put(victim, new Integer[]{0, 1});
}
if(pvp_table.containsKey(attacker))
{
pvp_entry = pvp_table.get(attacker);
pvp_entry[0]++;
pvp_table.put(attacker, pvp_entry);
}
else
{
pvp_table.put(attacker, new Integer[]{1, 0});
}
}
}
br.close();
}
catch(Exception e)
{
// Error loading file
}
return pvp_table;
}
%>
<%!
String toHexString(byte[] x)
{
StringBuffer sb = new StringBuffer(x.length * 2);
for (int i = 0; i < x.length; ++i)
{
byte n = x[i];
int nibble = n >> 4 & 0xF;
sb.append((char)((nibble >= 10) ? 97 + nibble - 10 : 48 + nibble));
nibble = n & 0xF;
sb.append((char)((nibble >= 10) ? 97 + nibble - 10 : 48 + nibble));
}
return sb.toString();
}
%>
<%!
byte[] hextoByteArray(String x)
{
if (x.length() < 2)
{
return new byte[0];
}
if (x.length() % 2 != 0)
{
System.err.println("hextoByteArray error! hex size=" + Integer.toString(x.length()));
}
byte[] rb = new byte[x.length() / 2];
for (int i = 0; i < rb.length; ++i)
{
rb[i] = 0;
int n = x.charAt(i + i);
if ((n >= 48) && (n <= 57))
n -= 48;
else
if ((n >= 97) && (n <= 102))
n = n - 97 + 10;
rb[i] = (byte)(rb[i] | n << 4 & 0xF0);
n = x.charAt(i + i + 1);
if ((n >= 48) && (n <= 57))
n -= 48;
else
if ((n >= 97) && (n <= 102))
n = n - 97 + 10;
rb[i] = (byte)(rb[i] | n & 0xF);
}
return rb;
}
%>
<%!
String int2occupation(String mode, int c)
{
if(mode.compareTo("pwi") == 0)
{
switch(c)
{
case 0: return "Blademaster";
case 1: return "Wizard";
case 2: return "Psychic";
case 3: return "Venomancer";
case 4: return "Barbarian";
case 5: return "Assassin";
case 6: return "Archer";
case 7: return "Cleric";
}
}
else
{
switch(c)
{
case 0: return "Warrior";
case 1: return "Mage";
case 2: return "Monk";
case 3: return "WereFox";
case 4: return "WereBeast";
case 5: return "Genie";
case 6: return "Archer";
case 7: return "Priest";
}
}
return "unknown";
}
%>
<%
String message = "<br>";
boolean allowed = false;
if(request.getSession().getAttribute("ssid") == null)
{
out.println("<p align=\"right\"><font color=\"#ee0000\"><b>Login for Character administration...</b></font></p>");
}
else
{
allowed = true;
}
int id = -1;
int uid = -1;
String name = "<br>";
String level = "";
String reputation = "";
String health = "";
String mana = "";
String exp = "";
String spirit = "";
String[] cultivation = new String[33];
String vigor = "<option value=\"0\"></option>";
String race = "";
String occupation = "";
String gender = "";
String spouse = "";
String faction = "";
String attribute = "";
String constitution = "";
String intelligence = "";
String strength = "";
String agility = "";
String patk_min = "";
String patk_max = "";
String pdef = "";
String matk_min = "";
String matk_max = "";
String mdef = "";
String status = "";
String creationtime = "";
String deletiontime = "";
String lastlogin = "";
String world = "";
String coordinateX = "";
String coordinateY = "";
String coordinateZ = "";
String cubiamount = "";
String cubipurchased = "";
String cubibought = "";
String cubiused = "";
String cubisold = "";
String pkmode = "";
String pkinvadertime = "";
String pkpariahtime = "";
int breakcol = 6;
String equipment = "<option value=\"0\"></option>";
String inventory = "<option value=\"0\"></option>";
String storage = "<option value=\"0\"></option>";
String pocket_coins = "";
String storehouse_coins = "";
if(allowed && request.getParameter("process") != null && request.getParameter("process").compareTo("sqlsync") == 0)
{
try
{
// { faction-id , [(String)name , (Integer)level, (Integer)member-count] }
HashMap<Integer, Object[]> factions = loadFactions(pw_server_path);
// { role-id , [faction-id , faction-rank] }
HashMap<Integer, Integer[]> faction_members = loadFactionMembers(pw_server_path);
// { faction-id , "domain_1;domain_2;domain_3" }
HashMap<Integer, String> faction_domains = loadFactionDomains(pw_server_path);
// { role-id , [kills , deaths] }
HashMap<Integer, Integer[]> pvp = loadPvP(pw_server_path + "logs/world2.formatlog");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
Statement statement = connection.createStatement();
Statement update = connection.createStatement();
ResultSet rs;
// drop table and re-create it (autoincrement reset)
//statement.execute("TRUNCATE TABLE roles");
statement.executeUpdate("DROP TABLE IF EXISTS roles");
statement.executeUpdate
(
"CREATE TABLE roles(" +
"account_id int(11) NOT NULL, " +
"role_id int(11) NOT NULL, " +
"role_name varchar(32) NOT NULL, " +
"role_level smallint(6) NOT NULL, " +
"role_race tinyint(4) NOT NULL, " +
"role_occupation tinyint(4) NOT NULL, " +
"role_gender tinyint(4) NOT NULL, " +
"role_spouse int(11) NOT NULL, " +
"faction_id int(11) NOT NULL, " +
"faction_name varchar(32) NOT NULL, " +
"faction_level int(11) NOT NULL, " +
"faction_domains varchar(132) NOT NULL, " +
"role_faction_rank int(11) NOT NULL, " +
"pvp_time int(11) NOT NULL, " +
"pvp_kills int(11) NOT NULL, " +
"pvp_deads int(11) NOT NULL" +
") " +
"ENGINE=InnoDB DEFAULT CHARSET=utf8;"
);
rs = (statement.executeQuery("SELECT ID FROM users"));
// go through all account id's and fetch roles + properties
Integer roleid;
RoleBean chr;
String rolename;
Object[] faction_entry;
Integer[] faction_member_entry;
String domains;
Integer[] pvp_entry;
while(rs.next())
{
// Get all character of current userid
DataVector dv = GameDB.getRolelist(rs.getInt("ID"));
if(dv != null)
{
Iterator itr = dv.iterator();
while(itr.hasNext())
{
IntOctets ios = (IntOctets)itr.next();
chr = GameDB.get(ios.m_int);
roleid = new Integer(ios.m_int);
rolename = StringEscapeUtils.escapeHtml(chr.base.name.getString());
if(pvp.containsKey(roleid))
{
pvp_entry = pvp.get(roleid);
}
else
{
pvp_entry = new Integer[]{0, 0};
}
if(faction_members.containsKey(roleid))
{
faction_member_entry = faction_members.get(roleid);
}
else
{
faction_member_entry = new Integer[]{0, 0};
}
if(factions.containsKey(faction_member_entry[0]))
{
faction_entry = factions.get(faction_member_entry[0]);
faction_entry[0] = new String();
}
else
{
faction_entry = new Object[]{new String(), (Integer)0, (Integer)0};
}
if(faction_domains.containsKey(faction_member_entry[0]))
{
domains = faction_domains.get(faction_member_entry[0]);
}
else
{
domains = "";
}
// insert row into table
update.executeUpdate("INSERT INTO roles VALUES (" + chr.user.userid + ", " + roleid + ", '" + rolename + "', " + chr.status.level + ", " + chr.base.race + ", " + chr.base.cls + ", " + chr.base.gender + ", " + chr.base.reserved1 + ", " + faction_member_entry[0] + ", '" + (String)(faction_entry[0]) + "', " + (Integer)(faction_entry[1]) + ", '" + domains + "', " + faction_member_entry[1] + ", " + chr.status.invader_time + ", " + pvp_entry[0] + ", " + pvp_entry[1] + ")");
}
}
}
update.close();
rs.close();
statement.close();
connection.close();
message = "<font color=\"#00cc00\"><b>Roles Imported to MySQL Table</b></font>";
}
catch(Exception e)
{
message = "<font color=\"#ee0000\"><b>Importing Roles to MySQL Failed</b></font>";
}
}
if(request.getParameter("show") != null && request.getParameter("show").compareTo("details") == 0)
{
//### Get Values
try
{
RoleBean character;
if(request.getParameter("type") != null && request.getParameter("type").compareTo("id") == 0)
{
id = Integer.parseInt(request.getParameter("ident"));
}
else
{
id = GameDB.getRoleIdByName(request.getParameter("ident"));
//id = GameDB.getRoleIdByName(new String(request.getParameter("ident").getBytes(), "GBK"));
}
character = GameDB.get(id);
uid = character.user.userid;
//### Apply Modifications
if(request.getParameter("process") != null && allowed)
{
if(request.getParameter("process").compareTo("save") == 0)
{
message = "";
boolean error = false;
try
{
character.status.worldtag = Integer.parseInt(request.getParameter("world"));
}
catch(Exception e)
{
message += "Invalid Value for World ID<br>";
error = true;
}
try
{
character.status.posx = Float.valueOf(request.getParameter("coordinateX").trim()).floatValue();
}
catch(Exception e)
{
message += "Invalid Value for Position X<br>";
error = true;
}
try
{
character.status.posz = Float.valueOf(request.getParameter("coordinateZ").trim()).floatValue();
}
catch(Exception e)
{
message += "Invalid Value for Position Z<br>";
error = true;
}
try
{
character.status.posy = Float.valueOf(request.getParameter("coordinateY").trim()).floatValue();
}
catch(Exception e)
{
message += "Invalid Value for Altitude<br>";
error = true;
}
try
{
character.status.reputation = Integer.parseInt(request.getParameter("reputation"));
}
catch(Exception e)
{
message += "Invalid Value for Reputation<br>";
error = true;
}
try
{
character.status.exp = Integer.parseInt(request.getParameter("exp"));
}
catch(Exception e)
{
message += "Invalid Value for EXP<br>";
error = true;
}
try
{
character.status.sp = Integer.parseInt(request.getParameter("sp"));
}
catch(Exception e)
{
message += "Invalid Value for SP<br>";
error = true;
}
try
{
character.status.level2 = Integer.parseInt(request.getParameter("cultivation"));
}
catch(Exception e)
{
message += "Invalid Value for Cultivation<br>";
error = true;
}
try
{
character.ep.max_ap = Integer.parseInt(request.getParameter("vigor"));
}
catch(Exception e)
{
message += "Invalid Value for Vigor Points<br>";
error = true;
}
try
{
character.pocket.money = Integer.parseInt(request.getParameter("pocketcoins"));
if(character.pocket.money > 200000000)
{
character.pocket.money = 200000000;
}
}
catch(Exception e)
{
message += "Invalid Value for Coins (Inventory)<br>";
error = true;
}
try
{
character.storehouse.money = Integer.parseInt(request.getParameter("storehousecoins"));
if(character.storehouse.money > 200000000)
{
character.storehouse.money = 200000000;
}
}
catch(Exception e)
{
message += "Invalid Value for Coins (Storage)<br>";
error = true;
}
try
{
if(request.getParameter("itemgroup") != "" && request.getParameter("itemindex") != "")
{
String group = request.getParameter("itemgroup");
int index = Integer.parseInt(request.getParameter("itemindex"));
if(request.getParameter("itemaction").equals("remove"))
{
if(group.equals("equipment"))
{
character.equipment.removeElementAt(index);
}
if(group.equals("inventory"))
{
character.pocket.items.removeElementAt(index);
}
if(group.equals("storage"))
{
character.storehouse.items.removeElementAt(index);
}
}
else
{
GRoleInventory gri = new GRoleInventory();
gri.id = Integer.parseInt(request.getParameter("itemid"));
gri.guid1 = Integer.parseInt(request.getParameter("itemguid1"));
gri.guid2 = Integer.parseInt(request.getParameter("itemguid2"));
gri.mask = Integer.parseInt(request.getParameter("itemmask"));
gri.proctype = Integer.parseInt(request.getParameter("itemproctype"));
gri.pos = Integer.parseInt(request.getParameter("itempos"));
gri.count = Integer.parseInt(request.getParameter("itemcount"));
gri.max_count = Integer.parseInt(request.getParameter("itemcountmax"));
gri.expire_date = Integer.parseInt(request.getParameter("itemexpire"));
gri.data = new Octets(hextoByteArray(request.getParameter("itemdata")));
if(request.getParameter("itemaction").equals("add"))
{
if(group.equals("equipment"))
{
character.equipment.addElement(gri);
}
if(group.equals("inventory"))
{
character.pocket.items.addElement(gri);
}
if(group.equals("storage"))
{
character.storehouse.items.addElement(gri);
}
}
if(request.getParameter("itemaction").equals("edit"))
{
if(group.equals("equipment"))
{
character.equipment.setElementAt(gri, index);
}
if(group.equals("inventory"))
{
character.pocket.items.setElementAt(gri, index);
}
if(group.equals("storage"))
{
character.storehouse.items.setElementAt(gri, index);
}
}
}
}
}
catch(Exception e)
{
message += "Invalid Values for Selected Item<br>";
error = true;
}
if(error)
{
message += "<font color=\"#ee0000\"><b>Check the Fields for incorrect Data</b></font>";
}
else
{
try
{
GameDB.update(character);
message = "<font color=\"#00cc00\"><b>Character Data Saved</b></font>";
}
catch(Exception e)
{
message = "<font color=\"#ee0000\"><b>Saving Character Data Failed</b></font>";
}
}
}
if(request.getParameter("process").compareTo("rename") == 0)
{
try
{
String newname = request.getParameter("rolename");
if(newname.length() < 1 || newname.length() > 9)
{
message = "<font color=\"#ee0000\"><b>Only 1-9 Characters</b></font>";
}
else
{
String alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
boolean check = true;
char c;
for(int i=0; i<newname.length(); i++)
{
c = newname.charAt(i);
if (alphabet.indexOf(c) == -1)
{
check = false;
break;
}
}
if(!check)
{
message = "<font color=\"ee0000\">Forbidden Characters</font>";
}
else
{
if(GameDB.renameRole(id, character.base.name.getString(), newname) == 0)
{
// Register the new name
//UniquenameDB.PostCreateRole((byte)1, 1, id, newname);
// Unregister the old name / don't work for the origin name :-(
UniquenameDB.PostDeleteRole(0, id, character.base.name.getString());
message = "<font color=\"#00cc00\"><b>Character Renamed</b></font>";
}
else
{
message = "<font color=\"#ee0000\"><b>Another Character with this Name exists</b></font>";
}
}
}
}
catch(Exception e)
{
message = "<font color=\"#ee0000\"><b>Renaming Character Failed</b></font>";
}
}
if(request.getParameter("process").compareTo("delete") == 0)
{
try
{
if(GameDB.deleteRolePermanent(id))
{
// Make the name available
UniquenameDB.PostDeleteRole(0, id, character.base.name.getString());
character = GameDB.get(id);
message = "<font color=\"#00cc00\"><b>Character Deleted</b></font>";
}
else
{
message = "<font color=\"#ee0000\"><b>Deleting Character Failed</b></font>";
}
}
catch(Exception e)
{
message = "<font color=\"#ee0000\"><b>Deleting Character Failed</b></font>";
}
}
}
//### End Apply
name = StringEscapeUtils.escapeHtml(character.base.name.getString());
level = Integer.toString(character.status.level);
reputation = Integer.toString(character.status.reputation);
health = Integer.toString(character.ep.max_hp);
mana = Integer.toString(character.ep.max_mp);
exp = Integer.toString(character.status.exp);
spirit = Integer.toString(character.status.sp);
cultivation = new String[32+1];
for(int i=0; i<cultivation.length; i++)
{
if(i == character.status.level2)
{
cultivation[i] = " selected=\"selected\"";
}
else
{
cultivation[i] = "";
}
}
switch(character.ep.max_ap)
{
case 99: vigor = "<option value=\"0\">000</option><option value=\"99\" selected=\"selected\">099</option><option value=\"199\">199</option><option value=\"299\">299</option><option value=\"399\">399</option>"; break;
case 199: vigor = "<option value=\"0\">000</option><option value=\"99\">099</option><option value=\"199\" selected=\"selected\">199</option><option value=\"299\">299</option><option value=\"399\">399</option>"; break;
case 299: vigor = "<option value=\"0\">000</option><option value=\"99\">099</option><option value=\"199\">199</option><option value=\"299\" selected=\"selected\">299</option><option value=\"399\">399</option>"; break;
case 399: vigor = "<option value=\"0\">000</option><option value=\"99\">099</option><option value=\"199\">199</option><option value=\"299\">299</option><option value=\"399\" selected=\"selected\">399</option>"; break;
default: vigor = "<option value=\"0\" selected=\"selected\">000</option><option value=\"99\">099</option><option value=\"199\">199</option><option value=\"299\">299</option><option value=\"399\">399</option>"; break;
}
switch(character.base.race)
{
case 0: race = "Human"; break;
case 1: race = "Beast"; break;
case 2: race = "Beast"; break;
case 3: race = "Tideborn"; break;
case 4: race = "Elf"; break;
case 5: race = "Elf"; break;
default: race = "Unknown";
}
occupation = int2occupation(item_labels, character.base.cls);
gender = (character.base.gender == 0) ? "Male" : "Female";
if(character.base.reserved1 != 0)
{
try
{
spouse = StringEscapeUtils.escapeHtml(GameDB.get(character.base.reserved1).base.name.getString());
}
catch(Exception e)
{
spouse = "INVALID";
}
}
faction = "";
attribute = Integer.toString(character.status.pp);
constitution = Integer.toString(character.ep.vitality);
intelligence = Integer.toString(character.ep.energy);
strength = Integer.toString(character.ep.strength);
agility = Integer.toString(character.ep.agility);
patk_min = Integer.toString(character.ep.damage_low);
patk_max = Integer.toString(character.ep.damage_high);
pdef = Integer.toString(character.ep.defense);
matk_min = Integer.toString(character.ep.damage_magic_low);
matk_max = Integer.toString(character.ep.damage_magic_high);
mdef = Integer.toString(character.ep.resistance[0]);
status = Integer.toString(character.base.status);
creationtime = (character.base.create_time <= 0) ? "-" : (new SimpleDateFormat("yyyy-MM-dd - HH:mm:ss")).format(new java.util.Date(1000*(long)character.base.create_time));
deletiontime = (character.base.delete_time <= 0) ? "-" : (new SimpleDateFormat("yyyy-MM-dd - HH:mm:ss")).format(new java.util.Date(1000*(long)character.base.delete_time));
lastlogin = (character.base.lastlogin_time <= 0) ? "-" : (new SimpleDateFormat("yyyy-MM-dd - HH:mm:ss")).format(new java.util.Date(1000*(long)character.base.lastlogin_time));
world = Integer.toString(character.status.worldtag);
coordinateX = (new DecimalFormat("#.##")).format(character.status.posx);
coordinateY = (new DecimalFormat("#.##")).format(character.status.posy);
coordinateZ = (new DecimalFormat("#.##")).format(character.status.posz);
cubiamount = (new DecimalFormat("#.##")).format((double)character.user.cash/100);
cubipurchased = (new DecimalFormat("#.##")).format((double)character.user.cash_add/100);
cubibought = (new DecimalFormat("#.##")).format((double)character.user.cash_buy/100);;
cubiused = (new DecimalFormat("#.##")).format((double)character.user.cash_used/100);;
cubisold = (new DecimalFormat("#.##")).format((double)character.user.cash_sell/100);;
pkmode = (character.status.invader_state == 0) ? "Off" : "On";
pkinvadertime = Integer.toString(character.status.invader_time);
pkpariahtime = Integer.toString(character.status.pariah_time);
pocket_coins = Integer.toString(character.pocket.money);
storehouse_coins = Integer.toString(character.storehouse.money);
String[] item_db = (String[])request.getSession().getAttribute("items");
equipment = "";
String icon = "";
if(character.equipment != null)
{
Iterator itr = character.equipment.iterator();
GRoleInventory gre;
String label;
int br = 0;
while(itr.hasNext())
{
if(br%breakcol == 0)
{
equipment += "<tr>";
}
gre = (GRoleInventory)itr.next();
try
{
label = item_db[gre.id];
}
catch(Exception e)
{
label = "<span class=\\'item_color0\\'>Item not found</span>";
}
if((new File(request.getRealPath("/include/icons/" + gre.id + ".gif"))).exists())
{
icon = "./include/icons/" + gre.id + ".gif";
}
else
{
icon = "./include/icons/0.gif";
}
equipment += "<td align=\"center\" onclick=\"select_item('" + label + "', 'equipment', '" + br + "', '" + gre.id + "', '" + gre.guid1 + "', '" + gre.guid2 + "', '" + gre.mask + "', '" + gre.proctype + "', '" + gre.pos + "', '" + gre.count + "', '" + gre.max_count + "', '" + gre.expire_date + "', '" + toHexString(gre.data.getBytes()) + "');\"><img title=\"" + gre.id + "\" src=\"" + icon + "\"></img></td>";
br++;
if(br%breakcol == 0)
{
equipment += "</tr>";
}
}
if(br%breakcol != 0)
{
// Fill Rest
while(br%breakcol != 0)
{
equipment += "<td><br></td>";
br++;
}
equipment += "</tr>";
}
}
inventory = "";
if(character.pocket.items != null)
{
Iterator itr = character.pocket.items.iterator();
GRoleInventory grp;
String label;
int br = 0;
while(itr.hasNext())
{
if(br%breakcol == 0)
{
inventory += "<tr>";
}
grp = (GRoleInventory)itr.next();
try
{
label = item_db[grp.id];
}
catch(Exception e)
{
label = "<span class=\\'item_color0\\'>Item not found</span>";
}
if((new File(request.getRealPath("/include/icons/" + grp.id + ".gif"))).exists())
{
icon = "./include/icons/" + grp.id + ".gif";
}
else
{
icon = "./include/icons/0.gif";
}
inventory += "<td align=\"center\" onclick=\"select_item('" + label + "', 'inventory', '" + br + "', '" + grp.id + "', '" + grp.guid1 + "', '" + grp.guid2 + "', '" + grp.mask + "', '" + grp.proctype + "', '" + grp.pos + "', '" + grp.count + "', '" + grp.max_count + "', '" + grp.expire_date + "', '" + toHexString(grp.data.getBytes()) + "');\"><img title=\"" + grp.id + "\" src=\"" + icon + "\"></img></td>";
br++;
if(br%breakcol == 0)
{
inventory += "</tr>";
}
}
if(br%breakcol != 0)
{
// Fill Rest
while(br%breakcol != 0)
{
inventory += "<td><br></td>";
br++;
}