Updated Copyright year to 2013
[getmangos.git] / contrib / extractor_binary / MoveMapGen.sh
blob495e3f9870bf9cd6da3f77119ed55ea6ecb472c1
1 #!/bin/sh
3 # Copyright (C) 2005-2013 MaNGOS project <http://getmangos.com/>
5 # This file is free software; as a special exception the author gives
6 # unlimited permission to copy and/or distribute it, with or without
7 # modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 ## Syntax of this helper
14 ## First param must be number of to be used CPUs (only 1, 2, 3, 4 supported) or "offmesh" to recreate the special tiles from the OFFMESH_FILE
15 ## Second param can be an additional filename for storing log
16 ## Third param can be an addition filename for storing detailed log
18 ## Additional Parameters to be forwarded to MoveMapGen, see mmaps/readme for instructions
19 PARAMS="--silent"
21 ## Already a few map extracted, and don't care anymore
22 EXCLUDE_MAPS=""
23 #EXCLUDE_MAPS="0 1 530 571" # example to exclude the continents
25 ## Offmesh file
26 OFFMESH_FILE="offmesh.txt"
28 ## Normal log file (if not overwritten by second param
29 LOG_FILE="MoveMapGen.log"
30 ## Detailed log file
31 DETAIL_LOG_FILE="MoveMapGen_detailed.log"
33 ## ! Use below only for finetuning or if you know what you are doing !
35 ## All maps
36 MAP_LIST_A="1 37 543 595 289 572 529 562 531 269 47 649 650 599 548 559 429 230 573 349 13 25 409 229 43 48 546 553 547 604 545 90 576"
37 MAP_LIST_B="571 628 560 509 723 532 607 600 668 33 585 566 389 601 369 129 550 189 542 70 109 554 632 552 555 540 598 450 558 249 35 624 557"
38 MAP_LIST_C="0 631 609 534 533 619 469 602 329 580 615 578 36 556 44 565 544 34 617 608 618 449 616 42 451 582 584 586 587 588 589 590 591 592"
39 MAP_LIST_D="530 169 575 603 309 574 30 564 568 209 724 658 489 593 594 596 597 605 606 610 612 613 614 620 621 622 623 641 642 647 672 673 712 713 718"
40 MAP_LIST_D1="209 724 658 489 606 610 612 613 614 620 621"
41 MAP_LIST_D2="169 575 603 309 574 30 564 568 622 623 641 642 647 672 673 712 713 718"
42 MAP_LIST_D3="530 593 594 596 597 605"
44 badParam()
46 echo "ERROR! Bad arguments!"
47 echo "You can (re)extract mmaps with this helper script,"
48 echo "or recreate only the tiles from the offmash file"
49 echo
50 echo "Call with number of processes (1 - 4) to create mmaps"
51 echo "Call with 'offmesh' to reextract the tiles from offmash file"
52 echo
53 echo "For further fine-tuning edit this helper script"
54 echo
57 if [ "$#" = "3" ]
58 then
59 LOG_FILE=$2
60 DETAIL_LOG_FILE=$3
61 elif [ "$#" = "2" ]
62 then
63 LOG_FILE=$2
66 # Offmesh file provided?
67 OFFMESH=""
68 if [ "$OFFMESH_FILE" != "" ]
69 then
70 if [ ! -f "$OFFMESH_FILE" ]
71 then
72 echo "ERROR! Offmesh file $OFFMESH_FILE could not be found."
73 echo "Provide valid file or none. You need to edit the script"
74 exit 1
75 else
76 OFFMESH="--offMeshInput $OFFMESH_FILE"
80 # Function to process a list
81 createMMaps()
83 for i in $@
85 for j in $EXCLUDE_MAPS
87 if [ "$i" = "$j" ]
88 then
89 continue 2
91 done
92 ./MoveMapGen $PARAMS $OFFMESH $i | tee -a $DETAIL_LOG_FILE
93 echo "`date`: (Re)created map $i" | tee -a $LOG_FILE
94 done
97 createHeader()
99 echo "`date`: Start creating MoveMaps" | tee -a $LOG_FILE
100 echo "Used params: $PARAMS $OFFMESH" | tee -a $LOG_FILE
101 echo "Detailed log can be found in $DETAIL_LOG_FILE" | tee -a $LOG_FILE
102 echo "Start creating MoveMaps" | tee -a $DETAIL_LOG_FILE
103 echo
104 echo "Be PATIENT - This will take a long time and might also have gaps between visible changes on the console."
105 echo "WAIT until you are informed that 'creating MoveMaps' is 'finished'!"
108 # Create mmaps directory if not exist
109 if [ ! -d mmaps ]
110 then
111 mkdir mmaps
114 # Param control
115 case "$1" in
116 "1" )
117 createHeader $1
118 createMMaps $MAP_LIST_A $MAP_LIST_B $MAP_LIST_C $MAP_LIST_D &
120 "2" )
121 createHeader $1
122 createMMaps $MAP_LIST_A $MAP_LIST_D &
123 createMMaps $MAP_LIST_B $MAP_LIST_C &
125 "3" )
126 createHeader $1
127 createMMaps $MAP_LIST_A $MAP_LIST_D1&
128 createMMaps $MAP_LIST_B $MAP_LIST_D2&
129 createMMaps $MAP_LIST_C $MAP_LIST_D3&
131 "4" )
132 createHeader $1
133 createMMaps $MAP_LIST_A &
134 createMMaps $MAP_LIST_B &
135 createMMaps $MAP_LIST_C &
136 createMMaps $MAP_LIST_D &
138 "offmesh" )
139 echo "`date`: Recreate offmeshs from file $OFFMESH_FILE" | tee -a $LOG_FILE
140 echo "Recreate offmeshs from file $OFFMESH_FILE" | tee -a $DETAIL_LOG_FILE
141 while read map tile line
143 ./MoveMapGen $PARAMS $OFFMESH $map --tile $tile | tee -a $DETAIL_LOG_FILE
144 echo "`date`: Recreated $map $tile from $OFFMESH_FILE" | tee -a $LOG_FILE
145 done < $OFFMESH_FILE &
148 badParam
149 exit 1
151 esac
153 wait
155 echo | tee -a $LOG_FILE
156 echo | tee -a $DETAIL_LOG_FILE
157 echo "`date`: Finished creating MoveMaps" | tee -a $LOG_FILE
158 echo "`date`: Finished creating MoveMaps" >> $DETAIL_LOG_FILE