1 create or replace package body loader as
3 procedure get_version_number(current_version in out number, min_version in out number)
6 select version_number, min_version_number
7 into current_version, min_version
11 function get_character_name_list return cursortype
13 result_cursor cursortype;
15 -- free up names that aren't in use anymore
17 where not exists (select 1 from objects where objects.object_id = character_object);
19 open result_cursor for
20 select character_object, station_id, uc_character_name, character_full_name,
21 (create_time - to_date('01/01/1970', 'MM/DD/YYYY')) * 24 * 3600,
22 (last_login_time - to_date('01/01/1970', 'MM/DD/YYYY')) * 24 * 3600
28 function locate_player (p_object_id number) return number
31 insert into object_list (object_id, container_level)
34 where load_with = p_object_id and deleted = 0;
39 procedure locate_universe
42 insert into object_list (object_id)
44 from objects o, universe_objects u
45 where o.object_id = u.object_id
49 procedure locate_contained_object (p_container_id number, p_object_id number)
52 insert into object_list (object_id, container_level)
56 o.object_id = p_object_id
57 and o.contained_by = p_container_id
60 prior o.object_id = o.contained_by
64 function locate_by_loadwith_batch (p_loadwiths vaofstring, p_chunk_size number)
68 forall i in 1..p_chunk_size
69 insert into object_list (object_id)
72 where o.load_with = p_loadwiths(i) and o.deleted = 0;
77 procedure locate_contents (p_container_id number)
80 insert into object_list (object_id, container_level)
83 where o.load_with = p_container_id and o.deleted = 0;
86 procedure locate_structure (p_object_id number, p_x out number, p_z out number, p_scene_id out varchar2, p_found out number)
89 select x, z, scene_id, 1 into p_x, p_z, p_scene_id, p_found
91 where object_id = p_object_id and deleted = 0 and
92 type_id in (1112885583, -- BuildingObject
93 1212763727, -- HarvesterInstallationObject
94 1229869903, -- InstallationObject
95 1296649807); -- ManufactureInstallationObject
97 when no_data_found then
101 function get_characters (p_station_id number) return cursortype
103 result_cursor cursortype;
105 open result_cursor for
116 where station_id = p_station_id;
118 return result_cursor;
121 function load_chunk_object_list (p_scene_id varchar, p_node_x float, p_node_z float) return number
128 where node_x = p_node_x
129 and node_z = p_node_z
130 and scene_id = p_scene_id
134 insert into object_list (object_id, container_level)
135 select object_id, level
139 and node_z = p_node_z
140 and scene_id = p_scene_id
143 and player_controlled = 'N'
145 prior object_id = contained_by
147 and player_controlled='N'
148 and prior load_contents='Y';
156 function load_manf_schematic_attributes return cursortype
158 result_cursor cursortype;
160 open result_cursor for
161 select /*+ ORDERED USE_NL(T) */ t.object_id, t.attribute_type, t.value
164 manf_schematic_attributes t
165 where t.object_id = l.object_id;
167 return result_cursor;
170 function load_armor return cursortype
172 result_cursor cursortype;
174 open result_cursor for
175 select /*+ ORDERED USE_NL(T) */
181 t.special_protections,
194 where t.object_id = l.object_id;
196 return result_cursor;
199 function load_scripts return cursortype
201 result_cursor cursortype;
203 open result_cursor for
204 select /*+ ORDERED USE_NL(T)*/
205 t.object_id, t.script, t.sequence_no
209 where t.object_id = l.object_id;
211 return result_cursor;
214 function load_object_variables return cursortype
216 result_cursor cursortype;
218 open result_cursor for
219 select /*+ ORDERED USE_NL(T)*/
220 t.object_id, t.name_id, t.type, t.value
224 where l.object_id = t.object_id
225 and nvl(t.detached,0) = 0;
227 return result_cursor;
230 function load_property_lists return cursortype
232 result_cursor cursortype;
234 open result_cursor for
235 select /*+ ORDERED USE_NL(T) */
236 t.object_id, t.list_id, t.value
237 from object_list l, property_lists t
238 where t.object_id = l.object_id;
240 return result_cursor;
243 function load_experience return cursortype
245 result_cursor cursortype;
247 open result_cursor for
248 select /*+ ORDERED USE_NL(T) */
249 t.object_id, t.experience_type, t.points
250 from object_list l, experience_points t
251 where t.object_id = l.object_id;
253 return result_cursor;
256 function load_battlefield_participants return cursortype
258 result_cursor cursortype;
260 open result_cursor for
261 select t.region_object_id, t.character_object_id, t.faction_id /*+ ORDERED USE_NL(T) */
262 from object_list l, battlefield_participants t
263 where t.region_object_id = l.object_id; -- order does not matter
265 return result_cursor;
268 function load_messages return cursortype
270 result_cursor cursortype;
272 open result_cursor for
273 select /*+ ORDERED USE_NL(MESSAGES) */
274 target, message_id, method, data, call_time, guaranteed, delivery_type
275 from object_list, messages
276 where target =object_list.object_id;
278 return result_cursor;
281 function load_location return cursortype
283 result_cursor cursortype;
285 open result_cursor for
286 select /*+ ORDERED USE_NL(T) */
299 where t.object_id = l.object_id;
301 return result_cursor;
307 result_cursor cursortype;
309 open result_cursor for
310 select /*+ ORDERED USE_NL(T) */
340 nvl(static_item_version,0),
341 nvl(conversion_id,0),
409 t.object_id=l.object_id;
411 return result_cursor;
414 function verify_containment_chain(p_start_with_object_id in number) return number
417 -- 1 = containment chain is recursive and is in starting(character) object chain
418 -- (can be fixed by placing the object in the world if its a character)
419 -- 2 = containment chain is recursive but not in starting object chain (this must be fixed manually)
420 -- 3 = no recursion in containment chain
422 m_retval pls_integer;
427 select count(*) into m_temp
429 start with object_id = p_start_with_object_id
430 connect by prior object_id = contained_by
431 and object_id != p_start_with_object_id;
435 select count(*) into m_temp
437 start with object_id = p_start_with_object_id
438 connect by object_id = prior contained_by;
448 function fix_player_containment_chain(p_start_with_object_id in number) return number
451 -- 0 = database error
452 -- 4 = success fix player containment issues
454 PRAGMA AUTONOMOUS_TRANSACTION;
457 update objects set contained_by = 0 where object_id = p_start_with_object_id;
458 admin.fix_load_with(p_start_with_object_id, p_start_with_object_id);
470 procedure verify_character (p_station_id in number, p_character_id in number, p_gold_schema in varchar2, p_approved out varchar2, p_character_name out varchar2, p_scene_id out varchar2, p_container_id out number, p_x out number, p_y out number, p_z out number, p_containment_check out number)
473 -- p_containment_check is a flag indicating the containment stautus to be used for logging on the C sid
474 -- 0 = there was a database error trying to fix containment
475 -- 1 = there is a recursive containment error in the character object chain that wasn't fixed
476 -- 2 = there is a recursive containment error in the containment chain not in the character chain
477 -- 3 = the containment chain is ok
478 -- 4 = there was a recursive containment error in the character object chain that was fixed
480 m_containment_ok pls_integer;
489 -- check containment chain
490 m_containment_ok := verify_containment_chain(p_character_id);
492 -- if containment is bad for the character object try to fix it
493 if (m_containment_ok = 1) then
494 m_containment_ok := fix_player_containment_chain(p_character_id);
497 p_containment_check := m_containment_ok;
499 if (m_containment_ok >= 3) then
501 select object_name, scene_id, contained_by, x, y, z, ws_x, ws_y, ws_z
502 into p_character_name, p_scene_id, p_container_id, p_x, p_y, p_z, wsx, wsy, wsz
503 from players p, objects o, creature_objects c
504 where p.station_id = p_station_id
505 and p.character_object = p_character_id
506 and o.object_id = p.character_object
507 and c.object_id = o.object_id
510 if (p_container_id = 0) then
512 p_container_id := p_character_id;
517 select object_id, x,y,z,'Y'
518 into p_container_id, p_x, p_y, p_z, p_approved
521 start with object_id = p_character_id
522 connect by prior contained_by=object_id and prior scene_id=scene_id and player_controlled = 'N';
525 when no_data_found then
526 -- might be in a gold building
527 if (p_gold_schema is not null) then
530 'select object_id, x,y,z,''Y'' ' ||
531 'from ' || p_gold_schema || 'objects ' ||
532 'where contained_by=0 ' ||
533 'start with object_id = :container_id ' ||
534 'connect by prior contained_by=object_id'
535 into p_container_id, p_x, p_y, p_z, p_approved
536 using p_container_id;
539 when no_data_found then
540 select object_id, x,y,z,'Y'
541 into p_container_id, p_x, p_y, p_z, p_approved
543 where object_id = p_character_id;
546 select object_id, x,y,z,'Y'
547 into p_container_id, p_x, p_y, p_z, p_approved
549 where object_id = p_character_id;
556 select 'N' into p_approved from dual;
561 if ( wsx is not null ) then
571 set last_login_time = sysdate
572 where station_id = p_station_id
573 and character_object = p_character_id;
576 when no_data_found then
580 when too_many_rows then
593 function load_waypoint
596 result_cursor cursortype;
598 open result_cursor for
599 select /*+ ORDERED USE_NL(T) */
602 t.appearance_name_crc,
615 t.object_id=l.object_id;
617 return result_cursor;
620 function load_player_object return cursortype
622 result_cursor cursortype;
624 open result_cursor for
625 select /*+ ORDERED USE_NL(T) USE_NL(A)*/
632 a.max_lots_adjustment,
633 t.personal_profile_id,
634 t.character_profile_id,
651 nvl(t.current_gcw_points,0),
652 nvl(t.current_gcw_rating,-1),
653 nvl(t.current_pvp_kills,0),
654 nvl(t.lifetime_gcw_points,0),
655 nvl(t.max_gcw_imperial_rating,-1),
656 nvl(t.max_gcw_rebel_rating,-1),
657 nvl(t.lifetime_pvp_kills,0),
658 nvl(t.next_gcw_rating_calc_time,0),
660 nvl(t.show_backpack,'Y'),
661 nvl(t.show_helmet,'Y'),
667 where t.station_id = a.station_id and
668 t.object_id=l.object_id;
670 return result_cursor;
673 function load_resource_types return cursortype
675 result_cursor cursortype;
677 open result_cursor for
688 return result_cursor;
691 function load_bounty_hunter_targets return cursortype
693 result_cursor cursortype;
695 open result_cursor for
696 select object_id, target_id
697 from bounty_hunter_targets
698 where target_id <> 0;
699 return result_cursor;
702 -- GENERATED PLSQL FOLLOWS
703 -- generated by makeloader.pl
705 function load_battlefield_marker_object return cursortype
707 result_cursor cursortype;
709 open result_cursor for
710 select /*+ ORDERED USE_NL(T) */
715 battlefield_marker_objects t
717 t.object_id=l.object_id;
719 return result_cursor;
722 function load_building_object return cursortype
724 result_cursor cursortype;
726 open result_cursor for
727 select /*+ ORDERED USE_NL(T) */
737 t.object_id=l.object_id;
739 return result_cursor;
742 function load_cell_object return cursortype
744 result_cursor cursortype;
746 open result_cursor for
747 select /*+ ORDERED USE_NL(T) */
755 t.object_id=l.object_id;
757 return result_cursor;
760 function load_city_object return cursortype
762 result_cursor cursortype;
764 open result_cursor for
765 select /*+ ORDERED USE_NL(T) */
771 t.object_id=l.object_id;
773 return result_cursor;
776 function load_creature_object return cursortype
778 result_cursor cursortype;
780 open result_cursor for
781 select /*+ ORDERED USE_NL(T) */
826 t.object_id=l.object_id;
828 return result_cursor;
831 function load_factory_object return cursortype
833 result_cursor cursortype;
835 open result_cursor for
836 select /*+ ORDERED USE_NL(T) */
842 t.object_id=l.object_id;
844 return result_cursor;
847 function load_guild_object return cursortype
849 result_cursor cursortype;
851 open result_cursor for
852 select /*+ ORDERED USE_NL(T) */
858 t.object_id=l.object_id;
860 return result_cursor;
863 function load_harvester_inst_object return cursortype
865 result_cursor cursortype;
867 open result_cursor for
868 select /*+ ORDERED USE_NL(T) */
870 t.installed_efficiency,
871 t.max_extraction_rate,
872 t.current_extraction_rate,
879 harvester_installation_objects t
881 t.object_id=l.object_id;
883 return result_cursor;
886 function load_installation_object return cursortype
888 result_cursor cursortype;
890 open result_cursor for
891 select /*+ ORDERED USE_NL(T) */
896 t.activate_start_time,
901 installation_objects t
903 t.object_id=l.object_id;
905 return result_cursor;
908 function load_intangible_object return cursortype
910 result_cursor cursortype;
912 open result_cursor for
913 select /*+ ORDERED USE_NL(T) */
920 t.object_id=l.object_id;
922 return result_cursor;
925 function load_manf_schematic_object return cursortype
927 result_cursor cursortype;
929 open result_cursor for
930 select /*+ ORDERED USE_NL(T) */
934 t.items_per_container,
939 manf_schematic_objects t
941 t.object_id=l.object_id;
943 return result_cursor;
946 function load_manufacture_inst_object return cursortype
948 result_cursor cursortype;
950 open result_cursor for
951 select /*+ ORDERED USE_NL(T) */
955 manufacture_inst_objects t
957 t.object_id=l.object_id;
959 return result_cursor;
962 function load_mission_object return cursortype
964 result_cursor cursortype;
966 open result_cursor for
967 select /*+ ORDERED USE_NL(T) */
996 t.object_id=l.object_id;
998 return result_cursor;
1001 function load_planet_object return cursortype
1003 result_cursor cursortype;
1005 open result_cursor for
1006 select /*+ ORDERED USE_NL(T) */
1013 t.object_id=l.object_id;
1015 return result_cursor;
1018 function load_resource_container_object return cursortype
1020 result_cursor cursortype;
1022 open result_cursor for
1023 select /*+ ORDERED USE_NL(T) */
1030 resource_container_objects t
1032 t.object_id=l.object_id;
1034 return result_cursor;
1037 function load_ship_object return cursortype
1039 result_cursor cursortype;
1041 open result_cursor for
1042 select /*+ ORDERED USE_NL(T) */
1045 t.current_chassis_hit_points,
1046 t.maximum_chassis_hit_points,
1048 t.cmp_armor_hp_maximum,
1049 t.cmp_armor_hp_current,
1050 t.cmp_efficiency_general,
1051 t.cmp_efficiency_eng,
1052 t.cmp_eng_maintenance,
1059 t.weapon_damage_maximum,
1060 t.weapon_damage_minimum,
1061 t.weapon_effectiveness_shields,
1062 t.weapon_effectiveness_armor,
1063 t.weapon_eng_per_shot,
1064 t.weapon_refire_rate,
1065 t.weapon_ammo_current,
1066 t.weapon_ammo_maximum,
1068 t.shield_hp_front_maximum,
1069 t.shield_hp_back_maximum,
1070 t.shield_recharge_rate,
1071 t.capacitor_eng_maximum,
1072 t.capacitor_eng_recharge_rate,
1074 t.engine_deceleration_rate,
1075 t.engine_pitch_acc_rate,
1076 t.engine_yaw_acc_rate,
1077 t.engine_roll_acc_rate,
1078 t.engine_pitch_rate_maximum,
1079 t.engine_yaw_rate_maximum,
1080 t.engine_roll_rate_maximum,
1081 t.engine_speed_maximum,
1082 t.reactor_eng_generation_rate,
1083 t.booster_eng_maximum,
1084 t.booster_eng_recharge_rate,
1085 t.booster_eng_consumption_rate,
1087 t.booster_speed_maximum,
1088 t.droid_if_cmd_speed,
1090 t.chassis_cmp_mass_maximum,
1092 t.cargo_hold_contents_maximum,
1093 t.cargo_hold_contents_current,
1094 t.cargo_hold_contents
1099 t.object_id=l.object_id;
1101 return result_cursor;
1104 function load_static_object return cursortype
1106 result_cursor cursortype;
1108 open result_cursor for
1109 select /*+ ORDERED USE_NL(T) */
1115 t.object_id=l.object_id;
1117 return result_cursor;
1120 function load_tangible_object return cursortype
1122 result_cursor cursortype;
1124 open result_cursor for
1125 select /*+ ORDERED USE_NL(T) */
1135 t.custom_appearance,
1139 t.source_draft_schematic
1144 t.object_id=l.object_id;
1146 return result_cursor;
1149 function load_token_object return cursortype
1151 result_cursor cursortype;
1153 open result_cursor for
1154 select /*+ ORDERED USE_NL(T) */
1157 t.target_server_template_name,
1158 t.target_shared_template_name,
1164 t.object_id=l.object_id;
1166 return result_cursor;
1169 function load_universe_object return cursortype
1171 result_cursor cursortype;
1173 open result_cursor for
1174 select /*+ ORDERED USE_NL(T) */
1180 t.object_id=l.object_id;
1182 return result_cursor;
1185 function load_vehicle_object return cursortype
1187 result_cursor cursortype;
1189 open result_cursor for
1190 select /*+ ORDERED USE_NL(T) */
1197 t.object_id=l.object_id;
1199 return result_cursor;
1202 function load_weapon_object return cursortype
1204 result_cursor cursortype;
1206 open result_cursor for
1207 select /*+ ORDERED USE_NL(T) */
1225 t.object_id=l.object_id;
1227 return result_cursor;
1231 function load_player_quest_object return cursortype
1233 result_cursor cursortype;
1235 open result_cursor for
1236 select /*+ ORDERED USE_NL(T) */
1244 t.task_description1,
1246 t.task_description2,
1248 t.task_description3,
1250 t.task_description4,
1252 t.task_description5,
1254 t.task_description6,
1256 t.task_description7,
1258 t.task_description8,
1260 t.task_description9,
1262 t.task_description10,
1264 t.task_description11,
1266 t.task_description12
1269 player_quest_objects t
1271 t.object_id=l.object_id;
1273 return result_cursor;