maps:map-technical
Differences
This shows you the differences between two versions of the page.
maps:map-technical [2018/03/30 09:48] – created karl | maps:map-technical [2018/04/03 12:21] (current) – moved to :maps:dev: folder karl | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Technical Information About Maps====== | ||
- | |||
- | This documented is intended to convey technical information on how Crossfire deals with the map objects and objects placed on the maps. \\ | ||
- | For the most part, I only intend document how the new code works, and not go too much into history on the older methods. \\ | ||
- | A lot of the map code was re-written in early July 2001, which changed how many things are dealt with. | ||
- | |||
- | Mark Wedel | ||
- | July 7, 2001 | ||
- | |||
- | ======1. Map Header====== | ||
- | |||
- | The map header is the section at the start of the map file that describes the maps characteristics. | ||
- | |||
- | The map variables now make some sense, and are only stored in the map structure itself. | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | tile_path_< | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ' | ||
- | |||
- | ======2. Map Objects====== | ||
- | |||
- | The objects within the map are saved in standard ' | ||
- | |||
- | arch <some name> | ||
- | x <some value> | ||
- | y <some value> | ||
- | <other object specific values> | ||
- | end | ||
- | |||
- | Note that x and y are in fact optional. | ||
- | |||
- | =====Multipart objects===== | ||
- | |||
- | Multipart objects pose a tricky problem, in that they have to appear together in the map file - this makes proper handling of layers hard to deal with. | ||
- | |||
- | In old map code, all the single spaces objects were saved, and then all the multi part objects were saved. | ||
- | |||
- | slaying shops/ | ||
- | hp 14 | ||
- | sp 14 | ||
- | x 1 | ||
- | y 13 | ||
- | end | ||
- | More | ||
- | arch store_magic_2 | ||
- | name Magic Shop | ||
- | slaying shops/ | ||
- | hp 14 | ||
- | sp 14 | ||
- | x 2 | ||
- | y 13 | ||
- | end | ||
- | <snip - there are really two more parts> | ||
- | |||
- | This method does not work very well with the map tiling however (how do you reasonably deal with a monster that may be straddling the two maps? | ||
- | |||
- | The effect of saving only the head does have the effect of not being able to customize the non head parts of the object. | ||
- | |||
- | ======3. Map Tiling======= | ||
- | |||
- | Map tiling is a feature that lets multiple maps be connected, effectively forming a much larger single map. This is most useful for the outdoor world maps, where it is not practical to have on massive map, but the old style tiling method (copying areas of the adjoining map to the next one) are not very efficient. | ||
- | |||
- | The transfer of objects from one map to another tiled map are automatic. | ||
- | |||
- | Notes: | ||
- | |||
- | Tiled maps must be the same width/ | ||
- | |||
- | |||
- | +---x1----+----x2---+ | ||
- | | | ||
- | | map1 | map2 y2 | ||
- | y1 | | | ||
- | | | ||
- | +---------+---------+ | ||
- | |||
- | x1 is the width of map1, y1 is its height. | ||
- | x2 is the width of map2, y2 is its height. | ||
- | map1 will tile map2 as indicated in the above diagram. | ||
- | |||
- | Given that, the following must be true: | ||
- | |||
- | y1 must equal y2 | ||
- | x1 must be greater than 12 | ||
- | x2 must be greater than 12 | ||
- | x1 and x2 do not need to be equal | ||
- | |||
- | The value is derived as being half the maximum viewable area. The reason for this is that the line of sight code (and likely some other code) will only look one map away from a source coordinate. | ||
- | |||
- | Note that tiles maps do not have to be symmetric - several maps could tile to a common map. That common map can only tile back to one of those. | ||
- | |||
- | ======4. Stacking of Objects on the Map====== | ||
- | |||
- | The stacking of objects on a map is somewhat confusing. | ||
- | |||
- | It is usually the appearance in the client the designers care most about. | ||
- | |||
- | When loading a map from disk, the server will keep the same stacking order as set in the map. Note however that multipart (big) objects are handled specially - because only the head of the object is saved, the stacking for the non head objects is always right above the floor. | ||
- | |||
- | Additional objects put on the space during play will generally be in stack order - newest object is on top. The one real exception is that flying objects (spells typically) will always be put on the top of the space, and then followed by non flying objects. | ||
- | |||
- | =====Layers===== | ||
- | |||
- | This ordering of objects in the server has little relation to how things appear in the client. | ||
- | |||
- | Floor (by definition, nothing beneath a floor is visible) | ||
- | no_pick (2) - things like signs, savebeds, runes | ||
- | item (3) - swords, armor, scrolls, arrows, etc | ||
- | living (2) - monsters | ||
- | fly (2) - spells, arrows, some monsters | ||
- | |||
- | The number in parentheses are the number of layers for those type of objects. So while there are 10 visible layers, in most cases, at least a few will not be used. If there are 50 items (swords, bows) on a space, the client will still only be sent information on 3 of them. It will not use the other layers, as only items will be sent in the items layer. | ||
- | |||
- | In most all cases, the server automatically figures out what layer an object belongs to based on various flags (FLAG_IS_FLOOR, | ||
- | |||
- | An object/map maker can override these values with the ' | ||
- | |||
- | There can be other cases where map maker want to change layering. | ||
- | |||
- | In cases of there being more objects of a type than can be displayed on a space, the first fallback is to look at the visibility of the defined face. Visibility is a face, not object, attribute, but is used when certain objects should take viewing precedence over others. | ||
- | |||
- | =====Visibility===== | ||
- | |||
- | If the visibility for the face is the same, the last fallback is server (map) stacking. | ||
- | |||
- | mace (50) | ||
- | sword (50) | ||
- | bow (100) | ||
- | shield (50) | ||
- | floor (50) (this is included just to make stacking order clear). | ||
- | |||
- | One might look at that and think that since shield is at the bottom and doesn' | ||
- | |||
- | But that is not the case - the high visibility of the bow causes it to be virtually placed above the other objects in the map view, so actual view would be bow, mace, sword, floor. | ||
- | |||
- | Because visibility is not an object attribute, there is generally little that can be done to control this, other than to set up the appropriate stacking. | ||
- | |||
- | ======5. Smoothing====== | ||
- | |||
- | Author Tchize | ||
- | Date: Seventh of July 2003 | ||
- | |||
- | =====Introduction to Smoothing===== | ||
- | |||
- | The crossfire graphical interface and internal map handling relies on a map made of square. No object can lies between squares. A typical square has the size of a standing player or other humanoïd sized creature (Goblins, Orcs, Gnolls, Dwarfs, Elves, ...). This lead to an awful interface concerning terrains transitions (Sea shores, road borders, mountains, a.s.o) | ||
- | |||
- | There are 2 ways to get rid of this problem: | ||
- | * Suppress the square by square behavior of map handling. This means rework half of Crossfire code and redraw all maps ... | ||
- | * Use some magic illusion. | ||
- | |||
- | =====What is Smoothing===== | ||
- | |||
- | Large discussions in the cf-devel mailing list was around a document on terrain transitions available on [http:// | ||
- | It explains a way of handling terrain transition in cases like the one of Crossfire. | ||
- | |||
- | Consider the smoothing in Crossfire as the ability for an object to draw itself partially above the surrounding squares. For example, grass could overlap just a bit the road next to it, a mountain would not end abruptly but instead would have some hills above the neighbor sand. | ||
- | |||
- | =====How to Smooth? | ||
- | |||
- | Next of this document is divided in 2 parts. \\ | ||
- | Drawers should be interested in the first part "Basic Smoothing" | ||
- | while developers may be interested also in [[# | ||
- | |||
- | ====Basic Smoothing==== | ||
- | |||
- | Basically, there need to be some order for smoothing. If everything draws itself above every surrounding square, we would end up with some awful bunch of crappy disgusting mixture of color (a Picasso or alike). | ||
- | |||
- | So, we come to the... | ||
- | |||
- | ===First Rule of Smoothing=== | ||
- | |||
- | An object O may draw itself above a neighbor object V if, and only if, O has a << | ||
- | |||
- | {{img: | ||
- | FIXME: Find image | ||
- | |||
- | O in the example picture has a higher priority than V so O will overlap V a bit but V will not overlap O. | ||
- | |||
- | The smoothlevel is an integer value ranging from 0 (overlap nothing) to 255 (overlap above everything except other objects having also smoothlevel of 255). This is important to consider when you are going to give the smoothing ability to new objects. Let's say, for example, you want to add this ability to mountains. Let's imagine has a smoothlevel of 10 and trees have a smoothlevel 100 (just imagine, at time writing this doc, nothing fixed yet). Now let's say you want the mountains above the grass but, for graphical reasons, you want the trees above the mountains. You Choose a value between 10 and 100, not included. But mountains is a thing that goes above a lot of thing (grass, hills, swamps, brush, rocks, desert, | ||
- | |||
- | So now you have chosen the smoothlevel for the mountain. What are you supposed to draw? You know what overlap what is decided by smoothlevel. But the graphics used during the smoothing is the... | ||
- | |||
- | ===Second Rule of Smoothing=== | ||
- | |||
- | The picture used to draw a given object depend on the face of the object. All objects using the grass face, for example, if they have a smoothlevel higher than 0, will be smooth using the same pictures. So you will bind with the picture grass.111 a set of pictures telling the client what to draw when smoothing an object having the face grass.111. | ||
- | |||
- | Take a look at the canvas below: | ||
- | |||
- | {{img: | ||
- | FIXME : Find image | ||
- | |||
- | Each square have a size of 32x32, which is the size used by the current image sets. This canvas handles all cases of corner, borders, L shaped, U shaped and O shaped transitions. The picture is made of 16 elements by 2. The first line is all border related transition. The second line is corner related transitions. Here is an example picture for grass (yeah really need someone to rework it): | ||
- | |||
- | {{img: | ||
- | FIXME : Find image | ||
- | |||
- | The picture is named sgrass.base.111.png and located in the ground/ | ||
- | |||
- | ===Final Rule of Smoothing=== | ||
- | |||
- | Tell the server which picture to send the client. There is, in the server SVN directory a file named lib/smooth. This file is where you set this information. Each line in the file beginning with ''#'' | ||
- | |||
- | The first is the picture you want to smooth (here it is grass.111), and the second is the 512x64 picture drawn at rule 2 and used when smoothing. | ||
- | |||
- | * Note Please note we suppressed the .png and the .base. elements of grass.base.111.png filename. Since what the server needs is the internal names. Take care of this. If the new picture you drew didn't appear on the GUI, this is perhaps due to an error in this file. And don't forget to copy this file, afterwards, to the install directory of server, using a make~install. | ||
- | |||
- | And example line might be as follows: | ||
- | |||
- | grass.111 sgrass.111 | ||
- | |||
- | The entry default '' | ||
- | This correspond to the black canvas above so mapmakers or drawers can see immediately, | ||
- | that there is a problem. | ||
- | |||
- | Now, drawers know everything. Coders might want to read following part. | ||
- | |||
- | ====Smoothing in the Code==== | ||
- | Back to [[#How to Smooth? | ||
- | |||
- | Guess what... | ||
- | |||
- | FIXME TODO | ||
maps/map-technical.1522421332.txt.gz · Last modified: (external edit)