0000026: Map aliases support

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

Patapum
Noob
Noob
Posts: 1
Joined: 16 Mar 2009, 00:50
Noob?: No

0000026: Map aliases support

#1 Post by Patapum »

http://bugtracker.openkore.com/view.php?id=26

Code: Select all

Index: Field.pm
===================================================================
--- Field.pm	(revision 6828)
+++ Field.pm	(working copy)
@@ -44,7 +44,7 @@
 use Compress::Zlib;
 use File::Spec;
 
-use Globals qw($masterServer %field);
+use Globals qw($masterServer %field %resnametable_lut);
 use Modules 'register';
 use Settings;
 use FastUtils;
@@ -356,19 +356,13 @@
 		# Some fields have multiple names, but have the same field data nevertheless.
 		# For example, the newbie grounds (new_1-1, new_2-1, etc.) all look the same,
 		# even though they're different fields and may have different monsters.
-		# Take care of that.
-		if ($name =~ /^new_\d-(\d)$/) {
-			$name = "new_zone0$1";
-		} elsif ($name =~ /^force_\d-(\d)$/) {
-			$name = "force_map$1";
-		} elsif ($name =~ /^pvp_n_\d-2$/) {
-			$name = "job_hunter";
-		} elsif ($name =~ /^pvp_n_\d-3$/) {
-			$name = "job_wizard";
-		} elsif ($name =~ /^pvp_n_\d-5$/) {
-			$name = "job_knight";
+		# Take care of that.		
+		if($resnametable_lut{"$name.gat"}){
+			$baseName = $resnametable_lut{"$name.gat"};
+			$baseName =~ s/\.gat$/.fld/i;
+		} else {
+			$baseName = "$name.fld";
 		}
-		$baseName = "$name.fld";
 	}
 
 	return $baseName;
Index: FileParsers.pm
===================================================================
--- FileParsers.pm	(revision 6828)
+++ FileParsers.pm	(working copy)
@@ -654,7 +654,7 @@
 }
 
 sub parseROLUT {
-	my ($file, $r_hash) = @_;
+	my ($file, $r_hash, $flag) = @_;
 
 	my %ret = (
 		file => $file,
@@ -672,7 +672,7 @@
 
 		my ($id, $name) = split /#/, $line, 3;
 		if ($id ne "" && $name ne "") {
-			$name =~ s/_/ /g;
+			$name =~ s/_/ /g if (!$flag);
 			$r_hash->{$id} = $name;
 		}
 	}
Index: functions.pl
===================================================================
--- functions.pl	(revision 6828)
+++ functions.pl	(working copy)
@@ -178,6 +178,7 @@
 	Settings::addTableFile('packetdescriptions.txt',  loader => [\&parseSectionedFile, \%packetDescriptions]);
 	Settings::addTableFile('portals.txt',     loader => [\&parsePortals, \%portals_lut]);
 	Settings::addTableFile('portalsLOS.txt',  loader => [\&parsePortalsLOS, \%portals_los]);
+	Settings::addTableFile('resnametable.txt',        loader => [\&parseROLUT, \%resnametable_lut, 1]);
 	Settings::addTableFile('servers.txt',     loader => [\&parseSectionedFile, \%masterServers]);
 	Settings::addTableFile('sex.txt',         loader => [\&parseDataFile2, \%sex_lut]);
 	Settings::addTableFile('skills.txt',      loader => \&Skill::StaticInfo::parseSkillsDatabase);
Index: Globals.pm
===================================================================
--- Globals.pm	(revision 6828)
+++ Globals.pm	(working copy)
@@ -26,7 +26,7 @@
 # Do not use any other Kore modules here. It will create circular dependancies.
 
 our %EXPORT_TAGS = (
-	config  => [qw(%arrowcraft_items %avoid @chatResponses %cities_lut %config %consoleColors %directions_lut %equipTypes_lut %equipSlot_rlut %equipSlot_lut %haircolors @headgears_lut %items_control %items_lut %itemSlotCount_lut %itemsDesc_lut %itemTypes_lut %jobs_lut %maps_lut %masterServers %monsters_lut %npcs_lut %packetDescriptions %portals_lut %responses %sex_lut %shop %skillsDesc_lut %skillsLooks %skillsArea %skillsEncore %skillsSP_lut %spells_lut %emotions_lut %timeout $char %mon_control %priority %routeWeights %pickupitems %rpackets %itemSlots_lut %skillsStatus %portals_los %skillsState %skillsAilments %elements_lut)],
+	config  => [qw(%arrowcraft_items %avoid @chatResponses %cities_lut %config %consoleColors %directions_lut %equipTypes_lut %equipSlot_rlut %equipSlot_lut %haircolors @headgears_lut %items_control %items_lut %itemSlotCount_lut %itemsDesc_lut %itemTypes_lut %jobs_lut %maps_lut %masterServers %monsters_lut %npcs_lut %packetDescriptions %portals_lut %responses %sex_lut %shop %skillsDesc_lut %skillsLooks %skillsArea %skillsEncore %skillsSP_lut %spells_lut %emotions_lut %timeout $char %mon_control %priority %routeWeights %pickupitems %rpackets %itemSlots_lut %skillsStatus %portals_los %skillsState %skillsAilments %elements_lut %resnametable_lut)],
 	ai      => [qw(@ai_seq @ai_seq_args %ai_v $AI $AI_forcedOff %targetTimeout)],
 	state   => [qw($accountID $cardMergeIndex @cardMergeItemsID $charID @chars @chars_old %cart @friendsID %friends %incomingFriend %field $field %homunculus $itemsList @itemsID %items $monstersList @monstersID %monsters @npcsID %npcs $npcsList @playersID %players @portalsID @portalsID_old %portals %portals_old $portalsList @storeList $currentChatRoom @currentChatRoomUsers @chatRoomsID %createdChatRoom %chatRooms @skillsID %storage @storageID @arrowCraftID %guild %incomingGuild @spellsID %spells @unknownPlayers @unknownNPCs $statChanged $skillChanged $useArrowCraft %currentDeal %incomingDeal %outgoingDeal @identifyID @partyUsersID %incomingParty @petsID %pets @venderItemList $venderID @venderListsID @articles $articles %venderLists %monsters_old @monstersID_old %npcs_old %items_old %players_old @playersID_old @servers $sessionID $sessionID2 $accountSex $accountSex2 $map_ip $map_port $KoreStartTime $secureLoginKey $initSync $lastConfChangeTime $petsList $playersList $portalsList @playerNameCacheIDs %playerNameCache %pet $pvp @cashList %repairList $slavesList @slavesID %slaves)],
 	network => [qw($remote_socket $net $messageSender $charServer $conState $conState_tries $encryptVal $ipc $bus $lastPacketTime $masterServer $lastswitch $packetParser $bytesSent $bytesReceived $incomingMessages $outgoingClientMessages $enc_val1 $enc_val2)],
@@ -106,6 +106,7 @@
 our %portals_los;
 our %portals_lut;
 our %priority;
+our %resnametable_lut;
 our %responses;
 our %routeWeights;
 our %rpackets;
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: 0000026: Map aliases support

#2 Post by Technology »

Well done Patapum. ;)

I've cleaned some code up and made it so kore only gets the information it needs (.gat data)

Committed!
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!