OpenTTD Source  1.11.0-beta1
screenshot.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "fileio_func.h"
12 #include "viewport_func.h"
13 #include "gfx_func.h"
14 #include "screenshot.h"
15 #include "blitter/factory.hpp"
16 #include "zoom_func.h"
17 #include "core/endian_func.hpp"
18 #include "saveload/saveload.h"
19 #include "company_base.h"
20 #include "company_func.h"
21 #include "strings_func.h"
22 #include "error.h"
23 #include "textbuf_gui.h"
24 #include "window_gui.h"
25 #include "window_func.h"
26 #include "tile_map.h"
27 #include "landscape.h"
28 
29 #include "table/strings.h"
30 
31 #include "safeguards.h"
32 
33 static const char * const SCREENSHOT_NAME = "screenshot";
34 static const char * const HEIGHTMAP_NAME = "heightmap";
35 
39 static char _screenshot_name[128];
40 char _full_screenshot_name[MAX_PATH];
41 
50 typedef void ScreenshotCallback(void *userdata, void *buf, uint y, uint pitch, uint n);
51 
63 typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette);
64 
67  const char *extension;
69 };
70 
71 #define MKCOLOUR(x) TO_LE32X(x)
72 
73 /*************************************************
74  **** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP)
75  *************************************************/
76 
78 PACK(struct BitmapFileHeader {
79  uint16 type;
80  uint32 size;
81  uint32 reserved;
82  uint32 off_bits;
83 });
84 static_assert(sizeof(BitmapFileHeader) == 14);
85 
88  uint32 size;
89  int32 width, height;
90  uint16 planes, bitcount;
91  uint32 compression, sizeimage, xpels, ypels, clrused, clrimp;
92 };
93 static_assert(sizeof(BitmapInfoHeader) == 40);
94 
96 struct RgbQuad {
97  byte blue, green, red, reserved;
98 };
99 static_assert(sizeof(RgbQuad) == 4);
100 
113 static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
114 {
115  uint bpp; // bytes per pixel
116  switch (pixelformat) {
117  case 8: bpp = 1; break;
118  /* 32bpp mode is saved as 24bpp BMP */
119  case 32: bpp = 3; break;
120  /* Only implemented for 8bit and 32bit images so far */
121  default: return false;
122  }
123 
124  FILE *f = fopen(name, "wb");
125  if (f == nullptr) return false;
126 
127  /* Each scanline must be aligned on a 32bit boundary */
128  uint bytewidth = Align(w * bpp, 4); // bytes per line in file
129 
130  /* Size of palette. Only present for 8bpp mode */
131  uint pal_size = pixelformat == 8 ? sizeof(RgbQuad) * 256 : 0;
132 
133  /* Setup the file header */
134  BitmapFileHeader bfh;
135  bfh.type = TO_LE16('MB');
136  bfh.size = TO_LE32(sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + pal_size + bytewidth * h);
137  bfh.reserved = 0;
138  bfh.off_bits = TO_LE32(sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + pal_size);
139 
140  /* Setup the info header */
141  BitmapInfoHeader bih;
142  bih.size = TO_LE32(sizeof(BitmapInfoHeader));
143  bih.width = TO_LE32(w);
144  bih.height = TO_LE32(h);
145  bih.planes = TO_LE16(1);
146  bih.bitcount = TO_LE16(bpp * 8);
147  bih.compression = 0;
148  bih.sizeimage = 0;
149  bih.xpels = 0;
150  bih.ypels = 0;
151  bih.clrused = 0;
152  bih.clrimp = 0;
153 
154  /* Write file header and info header */
155  if (fwrite(&bfh, sizeof(bfh), 1, f) != 1 || fwrite(&bih, sizeof(bih), 1, f) != 1) {
156  fclose(f);
157  return false;
158  }
159 
160  if (pixelformat == 8) {
161  /* Convert the palette to the windows format */
162  RgbQuad rq[256];
163  for (uint i = 0; i < 256; i++) {
164  rq[i].red = palette[i].r;
165  rq[i].green = palette[i].g;
166  rq[i].blue = palette[i].b;
167  rq[i].reserved = 0;
168  }
169  /* Write the palette */
170  if (fwrite(rq, sizeof(rq), 1, f) != 1) {
171  fclose(f);
172  return false;
173  }
174  }
175 
176  /* Try to use 64k of memory, store between 16 and 128 lines */
177  uint maxlines = Clamp(65536 / (w * pixelformat / 8), 16, 128); // number of lines per iteration
178 
179  uint8 *buff = MallocT<uint8>(maxlines * w * pixelformat / 8); // buffer which is rendered to
180  uint8 *line = AllocaM(uint8, bytewidth); // one line, stored to file
181  memset(line, 0, bytewidth);
182 
183  /* Start at the bottom, since bitmaps are stored bottom up */
184  do {
185  uint n = std::min(h, maxlines);
186  h -= n;
187 
188  /* Render the pixels */
189  callb(userdata, buff, h, w, n);
190 
191  /* Write each line */
192  while (n-- != 0) {
193  if (pixelformat == 8) {
194  /* Move to 'line', leave last few pixels in line zeroed */
195  memcpy(line, buff + n * w, w);
196  } else {
197  /* Convert from 'native' 32bpp to BMP-like 24bpp.
198  * Works for both big and little endian machines */
199  Colour *src = ((Colour *)buff) + n * w;
200  byte *dst = line;
201  for (uint i = 0; i < w; i++) {
202  dst[i * 3 ] = src[i].b;
203  dst[i * 3 + 1] = src[i].g;
204  dst[i * 3 + 2] = src[i].r;
205  }
206  }
207  /* Write to file */
208  if (fwrite(line, bytewidth, 1, f) != 1) {
209  free(buff);
210  fclose(f);
211  return false;
212  }
213  }
214  } while (h != 0);
215 
216  free(buff);
217  fclose(f);
218 
219  return true;
220 }
221 
222 /*********************************************************
223  **** SCREENSHOT CODE FOR PORTABLE NETWORK GRAPHICS (.PNG)
224  *********************************************************/
225 #if defined(WITH_PNG)
226 #include <png.h>
227 
228 #ifdef PNG_TEXT_SUPPORTED
229 #include "rev.h"
230 #include "newgrf_config.h"
231 #include "ai/ai_info.hpp"
232 #include "company_base.h"
233 #include "base_media_base.h"
234 #endif /* PNG_TEXT_SUPPORTED */
235 
236 static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
237 {
238  DEBUG(misc, 0, "[libpng] error: %s - %s", message, (const char *)png_get_error_ptr(png_ptr));
239  longjmp(png_jmpbuf(png_ptr), 1);
240 }
241 
242 static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
243 {
244  DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (const char *)png_get_error_ptr(png_ptr));
245 }
246 
259 static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
260 {
261  png_color rq[256];
262  FILE *f;
263  uint i, y, n;
264  uint maxlines;
265  uint bpp = pixelformat / 8;
266  png_structp png_ptr;
267  png_infop info_ptr;
268 
269  /* only implemented for 8bit and 32bit images so far. */
270  if (pixelformat != 8 && pixelformat != 32) return false;
271 
272  f = fopen(name, "wb");
273  if (f == nullptr) return false;
274 
275  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, const_cast<char *>(name), png_my_error, png_my_warning);
276 
277  if (png_ptr == nullptr) {
278  fclose(f);
279  return false;
280  }
281 
282  info_ptr = png_create_info_struct(png_ptr);
283  if (info_ptr == nullptr) {
284  png_destroy_write_struct(&png_ptr, (png_infopp)nullptr);
285  fclose(f);
286  return false;
287  }
288 
289  if (setjmp(png_jmpbuf(png_ptr))) {
290  png_destroy_write_struct(&png_ptr, &info_ptr);
291  fclose(f);
292  return false;
293  }
294 
295  png_init_io(png_ptr, f);
296 
297  png_set_filter(png_ptr, 0, PNG_FILTER_NONE);
298 
299  png_set_IHDR(png_ptr, info_ptr, w, h, 8, pixelformat == 8 ? PNG_COLOR_TYPE_PALETTE : PNG_COLOR_TYPE_RGB,
300  PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
301 
302 #ifdef PNG_TEXT_SUPPORTED
303  /* Try to add some game metadata to the PNG screenshot so
304  * it's more useful for debugging and archival purposes. */
305  png_text_struct text[2];
306  memset(text, 0, sizeof(text));
307  text[0].key = const_cast<char *>("Software");
308  text[0].text = const_cast<char *>(_openttd_revision);
309  text[0].text_length = strlen(_openttd_revision);
310  text[0].compression = PNG_TEXT_COMPRESSION_NONE;
311 
312  char buf[8192];
313  char *p = buf;
314  p += seprintf(p, lastof(buf), "Graphics set: %s (%u)\n", BaseGraphics::GetUsedSet()->name.c_str(), BaseGraphics::GetUsedSet()->version);
315  p = strecpy(p, "NewGRFs:\n", lastof(buf));
316  for (const GRFConfig *c = _game_mode == GM_MENU ? nullptr : _grfconfig; c != nullptr; c = c->next) {
317  p += seprintf(p, lastof(buf), "%08X ", BSWAP32(c->ident.grfid));
318  p = md5sumToString(p, lastof(buf), c->ident.md5sum);
319  p += seprintf(p, lastof(buf), " %s\n", c->filename);
320  }
321  p = strecpy(p, "\nCompanies:\n", lastof(buf));
322  for (const Company *c : Company::Iterate()) {
323  if (c->ai_info == nullptr) {
324  p += seprintf(p, lastof(buf), "%2i: Human\n", (int)c->index);
325  } else {
326  p += seprintf(p, lastof(buf), "%2i: %s (v%d)\n", (int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion());
327  }
328  }
329  text[1].key = const_cast<char *>("Description");
330  text[1].text = buf;
331  text[1].text_length = p - buf;
332  text[1].compression = PNG_TEXT_COMPRESSION_zTXt;
333  png_set_text(png_ptr, info_ptr, text, 2);
334 #endif /* PNG_TEXT_SUPPORTED */
335 
336  if (pixelformat == 8) {
337  /* convert the palette to the .PNG format. */
338  for (i = 0; i != 256; i++) {
339  rq[i].red = palette[i].r;
340  rq[i].green = palette[i].g;
341  rq[i].blue = palette[i].b;
342  }
343 
344  png_set_PLTE(png_ptr, info_ptr, rq, 256);
345  }
346 
347  png_write_info(png_ptr, info_ptr);
348  png_set_flush(png_ptr, 512);
349 
350  if (pixelformat == 32) {
351  png_color_8 sig_bit;
352 
353  /* Save exact colour/alpha resolution */
354  sig_bit.alpha = 0;
355  sig_bit.blue = 8;
356  sig_bit.green = 8;
357  sig_bit.red = 8;
358  sig_bit.gray = 8;
359  png_set_sBIT(png_ptr, info_ptr, &sig_bit);
360 
361 #if TTD_ENDIAN == TTD_LITTLE_ENDIAN
362  png_set_bgr(png_ptr);
363  png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
364 #else
365  png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
366 #endif /* TTD_ENDIAN == TTD_LITTLE_ENDIAN */
367  }
368 
369  /* use by default 64k temp memory */
370  maxlines = Clamp(65536 / w, 16, 128);
371 
372  /* now generate the bitmap bits */
373  void *buff = CallocT<uint8>(w * maxlines * bpp); // by default generate 128 lines at a time.
374 
375  y = 0;
376  do {
377  /* determine # lines to write */
378  n = std::min(h - y, maxlines);
379 
380  /* render the pixels into the buffer */
381  callb(userdata, buff, y, w, n);
382  y += n;
383 
384  /* write them to png */
385  for (i = 0; i != n; i++) {
386  png_write_row(png_ptr, (png_bytep)buff + i * w * bpp);
387  }
388  } while (y != h);
389 
390  png_write_end(png_ptr, info_ptr);
391  png_destroy_write_struct(&png_ptr, &info_ptr);
392 
393  free(buff);
394  fclose(f);
395  return true;
396 }
397 #endif /* WITH_PNG */
398 
399 
400 /*************************************************
401  **** SCREENSHOT CODE FOR ZSOFT PAINTBRUSH (.PCX)
402  *************************************************/
403 
405 struct PcxHeader {
406  byte manufacturer;
407  byte version;
408  byte rle;
409  byte bpp;
410  uint32 unused;
411  uint16 xmax, ymax;
412  uint16 hdpi, vdpi;
413  byte pal_small[16 * 3];
414  byte reserved;
415  byte planes;
416  uint16 pitch;
417  uint16 cpal;
418  uint16 width;
419  uint16 height;
420  byte filler[54];
421 };
422 static_assert(sizeof(PcxHeader) == 128);
423 
436 static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
437 {
438  FILE *f;
439  uint maxlines;
440  uint y;
441  PcxHeader pcx;
442  bool success;
443 
444  if (pixelformat == 32) {
445  DEBUG(misc, 0, "Can't convert a 32bpp screenshot to PCX format. Please pick another format.");
446  return false;
447  }
448  if (pixelformat != 8 || w == 0) return false;
449 
450  f = fopen(name, "wb");
451  if (f == nullptr) return false;
452 
453  memset(&pcx, 0, sizeof(pcx));
454 
455  /* setup pcx header */
456  pcx.manufacturer = 10;
457  pcx.version = 5;
458  pcx.rle = 1;
459  pcx.bpp = 8;
460  pcx.xmax = TO_LE16(w - 1);
461  pcx.ymax = TO_LE16(h - 1);
462  pcx.hdpi = TO_LE16(320);
463  pcx.vdpi = TO_LE16(320);
464 
465  pcx.planes = 1;
466  pcx.cpal = TO_LE16(1);
467  pcx.width = pcx.pitch = TO_LE16(w);
468  pcx.height = TO_LE16(h);
469 
470  /* write pcx header */
471  if (fwrite(&pcx, sizeof(pcx), 1, f) != 1) {
472  fclose(f);
473  return false;
474  }
475 
476  /* use by default 64k temp memory */
477  maxlines = Clamp(65536 / w, 16, 128);
478 
479  /* now generate the bitmap bits */
480  uint8 *buff = CallocT<uint8>(w * maxlines); // by default generate 128 lines at a time.
481 
482  y = 0;
483  do {
484  /* determine # lines to write */
485  uint n = std::min(h - y, maxlines);
486  uint i;
487 
488  /* render the pixels into the buffer */
489  callb(userdata, buff, y, w, n);
490  y += n;
491 
492  /* write them to pcx */
493  for (i = 0; i != n; i++) {
494  const uint8 *bufp = buff + i * w;
495  byte runchar = bufp[0];
496  uint runcount = 1;
497  uint j;
498 
499  /* for each pixel... */
500  for (j = 1; j < w; j++) {
501  uint8 ch = bufp[j];
502 
503  if (ch != runchar || runcount >= 0x3f) {
504  if (runcount > 1 || (runchar & 0xC0) == 0xC0) {
505  if (fputc(0xC0 | runcount, f) == EOF) {
506  free(buff);
507  fclose(f);
508  return false;
509  }
510  }
511  if (fputc(runchar, f) == EOF) {
512  free(buff);
513  fclose(f);
514  return false;
515  }
516  runcount = 0;
517  runchar = ch;
518  }
519  runcount++;
520  }
521 
522  /* write remaining bytes.. */
523  if (runcount > 1 || (runchar & 0xC0) == 0xC0) {
524  if (fputc(0xC0 | runcount, f) == EOF) {
525  free(buff);
526  fclose(f);
527  return false;
528  }
529  }
530  if (fputc(runchar, f) == EOF) {
531  free(buff);
532  fclose(f);
533  return false;
534  }
535  }
536  } while (y != h);
537 
538  free(buff);
539 
540  /* write 8-bit colour palette */
541  if (fputc(12, f) == EOF) {
542  fclose(f);
543  return false;
544  }
545 
546  /* Palette is word-aligned, copy it to a temporary byte array */
547  byte tmp[256 * 3];
548 
549  for (uint i = 0; i < 256; i++) {
550  tmp[i * 3 + 0] = palette[i].r;
551  tmp[i * 3 + 1] = palette[i].g;
552  tmp[i * 3 + 2] = palette[i].b;
553  }
554  success = fwrite(tmp, sizeof(tmp), 1, f) == 1;
555 
556  fclose(f);
557 
558  return success;
559 }
560 
561 /*************************************************
562  **** GENERIC SCREENSHOT CODE
563  *************************************************/
564 
567 #if defined(WITH_PNG)
568  {"png", &MakePNGImage},
569 #endif
570  {"bmp", &MakeBMPImage},
571  {"pcx", &MakePCXImage},
572 };
573 
576 {
578 }
579 
582 {
583  uint j = 0;
584  for (uint i = 0; i < lengthof(_screenshot_formats); i++) {
585  if (!strcmp(_screenshot_format_name, _screenshot_formats[i].extension)) {
586  j = i;
587  break;
588  }
589  }
592 }
593 
598 static void CurrentScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
599 {
601  void *src = blitter->MoveTo(_screen.dst_ptr, 0, y);
602  blitter->CopyImageToBuffer(src, buf, _screen.width, n, pitch);
603 }
604 
613 static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
614 {
615  Viewport *vp = (Viewport *)userdata;
616  DrawPixelInfo dpi, *old_dpi;
617  int wx, left;
618 
619  /* We are no longer rendering to the screen */
620  DrawPixelInfo old_screen = _screen;
621  bool old_disable_anim = _screen_disable_anim;
622 
623  _screen.dst_ptr = buf;
624  _screen.width = pitch;
625  _screen.height = n;
626  _screen.pitch = pitch;
627  _screen_disable_anim = true;
628 
629  old_dpi = _cur_dpi;
630  _cur_dpi = &dpi;
631 
632  dpi.dst_ptr = buf;
633  dpi.height = n;
634  dpi.width = vp->width;
635  dpi.pitch = pitch;
636  dpi.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
637  dpi.left = 0;
638  dpi.top = y;
639 
640  /* Render viewport in blocks of 1600 pixels width */
641  left = 0;
642  while (vp->width - left != 0) {
643  wx = std::min(vp->width - left, 1600);
644  left += wx;
645 
646  ViewportDoDraw(vp,
647  ScaleByZoom(left - wx - vp->left, vp->zoom) + vp->virtual_left,
648  ScaleByZoom(y - vp->top, vp->zoom) + vp->virtual_top,
649  ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
650  ScaleByZoom((y + n) - vp->top, vp->zoom) + vp->virtual_top
651  );
652  }
653 
654  _cur_dpi = old_dpi;
655 
656  /* Switch back to rendering to the screen */
657  _screen = old_screen;
658  _screen_disable_anim = old_disable_anim;
659 }
660 
668 static const char *MakeScreenshotName(const char *default_fn, const char *ext, bool crashlog = false)
669 {
670  bool generate = StrEmpty(_screenshot_name);
671 
672  if (generate) {
673  if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_company == COMPANY_SPECTATOR) {
675  } else {
677  }
678  }
679 
680  /* Add extension to screenshot file */
681  size_t len = strlen(_screenshot_name);
682  seprintf(&_screenshot_name[len], lastof(_screenshot_name), ".%s", ext);
683 
684  const char *screenshot_dir = crashlog ? _personal_dir.c_str() : FiosGetScreenshotDir();
685 
686  for (uint serial = 1;; serial++) {
688  /* We need more characters than MAX_PATH -> end with error */
689  _full_screenshot_name[0] = '\0';
690  break;
691  }
692  if (!generate) break; // allow overwriting of non-automatic filenames
693  if (!FileExists(_full_screenshot_name)) break;
694  /* If file exists try another one with same name, but just with a higher index */
695  seprintf(&_screenshot_name[len], lastof(_screenshot_name) - len, "#%u.%s", serial, ext);
696  }
697 
698  return _full_screenshot_name;
699 }
700 
702 static bool MakeSmallScreenshot(bool crashlog)
703 {
705  return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension, crashlog), CurrentScreenCallback, nullptr, _screen.width, _screen.height,
707 }
708 
715 {
716  switch(t) {
717  case SC_VIEWPORT:
718  case SC_CRASHLOG: {
721  vp->virtual_top = w->viewport->virtual_top;
724 
725  /* Compute pixel coordinates */
726  vp->left = 0;
727  vp->top = 0;
728  vp->width = _screen.width;
729  vp->height = _screen.height;
730  vp->overlay = w->viewport->overlay;
731  break;
732  }
733  case SC_WORLD: {
734  /* Determine world coordinates of screenshot */
736 
737  TileIndex north_tile = _settings_game.construction.freeform_edges ? TileXY(1, 1) : TileXY(0, 0);
738  TileIndex south_tile = MapSize() - 1;
739 
740  /* We need to account for a hill or high building at tile 0,0. */
741  int extra_height_top = TilePixelHeight(north_tile) + 150;
742  /* If there is a hill at the bottom don't create a large black area. */
743  int reclaim_height_bottom = TilePixelHeight(south_tile);
744 
745  vp->virtual_left = RemapCoords(TileX(south_tile) * TILE_SIZE, TileY(north_tile) * TILE_SIZE, 0).x;
746  vp->virtual_top = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(north_tile) * TILE_SIZE, extra_height_top).y;
747  vp->virtual_width = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, 0).x - vp->virtual_left + 1;
748  vp->virtual_height = RemapCoords(TileX(south_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, reclaim_height_bottom).y - vp->virtual_top + 1;
749 
750  /* Compute pixel coordinates */
751  vp->left = 0;
752  vp->top = 0;
753  vp->width = UnScaleByZoom(vp->virtual_width, vp->zoom);
754  vp->height = UnScaleByZoom(vp->virtual_height, vp->zoom);
755  vp->overlay = nullptr;
756  break;
757  }
758  default: {
760 
762  vp->virtual_left = w->viewport->virtual_left;
763  vp->virtual_top = w->viewport->virtual_top;
764  vp->virtual_width = w->viewport->virtual_width;
765  vp->virtual_height = w->viewport->virtual_height;
766 
767  /* Compute pixel coordinates */
768  vp->left = 0;
769  vp->top = 0;
770  vp->width = UnScaleByZoom(vp->virtual_width, vp->zoom);
771  vp->height = UnScaleByZoom(vp->virtual_height, vp->zoom);
772  vp->overlay = nullptr;
773  break;
774  }
775  }
776 }
777 
784 {
785  Viewport vp;
786  SetupScreenshotViewport(t, &vp);
787 
791 }
792 
802 static void HeightmapCallback(void *userdata, void *buffer, uint y, uint pitch, uint n)
803 {
804  byte *buf = (byte *)buffer;
805  while (n > 0) {
806  TileIndex ti = TileXY(MapMaxX(), y);
807  for (uint x = MapMaxX(); true; x--) {
808  *buf = 256 * TileHeight(ti) / (1 + _settings_game.construction.max_heightlevel);
809  buf++;
810  if (x == 0) break;
811  ti = TILE_ADDXY(ti, -1, 0);
812  }
813  y++;
814  n--;
815  }
816 }
817 
822 bool MakeHeightmapScreenshot(const char *filename)
823 {
824  Colour palette[256];
825  for (uint i = 0; i < lengthof(palette); i++) {
826  palette[i].a = 0xff;
827  palette[i].r = i;
828  palette[i].g = i;
829  palette[i].b = i;
830  }
832  return sf->proc(filename, HeightmapCallback, nullptr, MapSizeX(), MapSizeY(), 8, palette);
833 }
834 
836 
842 static void ScreenshotConfirmationCallback(Window *w, bool confirmed)
843 {
844  if (confirmed) MakeScreenshot(_confirmed_screenshot_type, nullptr);
845 }
846 
854 {
855  Viewport vp;
856  SetupScreenshotViewport(t, &vp);
857 
858  bool heightmap_or_minimap = t == SC_HEIGHTMAP || t == SC_MINIMAP;
859  uint64_t width = (heightmap_or_minimap ? MapSizeX() : vp.width);
860  uint64_t height = (heightmap_or_minimap ? MapSizeY() : vp.height);
861 
862  if (width * height > 8192 * 8192) {
863  /* Ask for confirmation */
865  SetDParam(0, width);
866  SetDParam(1, height);
867  ShowQuery(STR_WARNING_SCREENSHOT_SIZE_CAPTION, STR_WARNING_SCREENSHOT_SIZE_MESSAGE, nullptr, ScreenshotConfirmationCallback);
868  } else {
869  /* Less than 64M pixels, just do it */
870  MakeScreenshot(t, nullptr);
871  }
872 }
873 
882 bool MakeScreenshot(ScreenshotType t, const char *name)
883 {
884  if (t == SC_VIEWPORT) {
885  /* First draw the dirty parts of the screen and only then change the name
886  * of the screenshot. This way the screenshot will always show the name
887  * of the previous screenshot in the 'successful' message instead of the
888  * name of the new screenshot (or an empty name). */
889  UndrawMouseCursor();
890  DrawDirtyBlocks();
891  }
892 
893  _screenshot_name[0] = '\0';
894  if (name != nullptr) strecpy(_screenshot_name, name, lastof(_screenshot_name));
895 
896  bool ret;
897  switch (t) {
898  case SC_VIEWPORT:
899  ret = MakeSmallScreenshot(false);
900  break;
901 
902  case SC_CRASHLOG:
903  ret = MakeSmallScreenshot(true);
904  break;
905 
906  case SC_ZOOMEDIN:
907  case SC_DEFAULTZOOM:
908  case SC_WORLD:
909  ret = MakeLargeWorldScreenshot(t);
910  break;
911 
912  case SC_HEIGHTMAP: {
915  break;
916  }
917 
918  case SC_MINIMAP:
920  break;
921 
922  default:
923  NOT_REACHED();
924  }
925 
926  if (ret) {
928  ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING);
929  } else {
930  ShowErrorMessage(STR_ERROR_SCREENSHOT_FAILED, INVALID_STRING_ID, WL_ERROR);
931  }
932 
933  return ret;
934 }
935 
936 
944 {
945  Owner o;
946 
947  if (IsTileType(tile, MP_VOID)) {
948  return OWNER_END;
949  } else {
950  switch (GetTileType(tile)) {
951  case MP_INDUSTRY: o = OWNER_DEITY; break;
952  case MP_HOUSE: o = OWNER_TOWN; break;
953  default: o = GetTileOwner(tile); break;
954  /* FIXME: For MP_ROAD there are multiple owners.
955  * GetTileOwner returns the rail owner (level crossing) resp. the owner of ROADTYPE_ROAD (normal road),
956  * even if there are no ROADTYPE_ROAD bits on the tile.
957  */
958  }
959 
960  return o;
961  }
962 }
963 
964 static void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
965 {
966  /* Fill with the company colours */
967  byte owner_colours[OWNER_END + 1];
968  for (const Company *c : Company::Iterate()) {
969  owner_colours[c->index] = MKCOLOUR(_colour_gradient[c->colour][5]);
970  }
971 
972  /* Fill with some special colours */
973  owner_colours[OWNER_TOWN] = PC_DARK_RED;
974  owner_colours[OWNER_NONE] = PC_GRASS_LAND;
975  owner_colours[OWNER_WATER] = PC_WATER;
976  owner_colours[OWNER_DEITY] = PC_DARK_GREY; // industry
977  owner_colours[OWNER_END] = PC_BLACK;
978 
979  uint32 *ubuf = (uint32 *)buf;
980  uint num = (pitch * n);
981  for (uint i = 0; i < num; i++) {
982  uint row = y + (int)(i / pitch);
983  uint col = (MapSizeX() - 1) - (i % pitch);
984 
985  TileIndex tile = TileXY(col, row);
986  Owner o = GetMinimapOwner(tile);
987  byte val = owner_colours[o];
988 
989  uint32 colour_buf = 0;
990  colour_buf = (_cur_palette.palette[val].b << 0);
991  colour_buf |= (_cur_palette.palette[val].g << 8);
992  colour_buf |= (_cur_palette.palette[val].r << 16);
993 
994  *ubuf = colour_buf;
995  ubuf++; // Skip alpha
996  }
997 }
998 
1003 {
1005  return sf->proc(MakeScreenshotName(SCREENSHOT_NAME, sf->extension), MinimapScreenCallback, nullptr, MapSizeX(), MapSizeY(), 32, _cur_palette.palette);
1006 }
MP_HOUSE
@ MP_HOUSE
A house by a town.
Definition: tile_type.h:44
RgbQuad
Format of palette data in BMP header.
Definition: screenshot.cpp:96
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
factory.hpp
GetMinimapOwner
static Owner GetMinimapOwner(TileIndex tile)
Return the owner of a tile to display it with in the small map in mode "Owner".
Definition: screenshot.cpp:943
ScreenshotType
ScreenshotType
Type of requested screenshot.
Definition: screenshot.h:18
_personal_dir
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
Definition: fileio.cpp:1119
endian_func.hpp
ConstructionSettings::max_heightlevel
uint8 max_heightlevel
maximum allowed heightlevel
Definition: settings_type.h:305
PcxHeader
Definition of a PCX file header.
Definition: screenshot.cpp:405
WL_WARNING
@ WL_WARNING
Other information.
Definition: error.h:23
PC_DARK_RED
static const uint8 PC_DARK_RED
Dark red palette colour.
Definition: gfx_func.h:210
HeightmapCallback
static void HeightmapCallback(void *userdata, void *buffer, uint y, uint pitch, uint n)
Callback for generating a heightmap.
Definition: screenshot.cpp:802
company_base.h
Blitter
How all blitters should look like.
Definition: base.hpp:28
TilePixelHeight
static uint TilePixelHeight(TileIndex tile)
Returns the height of a tile in pixels.
Definition: tile_map.h:72
Viewport::width
int width
Screen width of the viewport.
Definition: viewport_type.h:25
SC_HEIGHTMAP
@ SC_HEIGHTMAP
Heightmap of the world.
Definition: screenshot.h:24
RemapCoords
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
Definition: landscape.h:82
Window::viewport
ViewportData * viewport
Pointer to viewport data, if present.
Definition: window_gui.h:326
Blitter::GetScreenDepth
virtual uint8 GetScreenDepth()=0
Get the screen depth this blitter works for.
Viewport::height
int height
Screen height of the viewport.
Definition: viewport_type.h:26
Viewport::top
int top
Screen coordinate top edge of the viewport.
Definition: viewport_type.h:24
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
BitmapInfoHeader
BMP Info Header (stored in little endian)
Definition: screenshot.cpp:87
saveload.h
zoom_func.h
TILE_SIZE
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:13
fileio_func.h
base_media_base.h
BaseSet::version
uint32 version
The version of this base set.
Definition: base_media_base.h:64
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
SC_ZOOMEDIN
@ SC_ZOOMEDIN
Fully zoomed in screenshot of the visible area.
Definition: screenshot.h:21
MP_INDUSTRY
@ MP_INDUSTRY
Part of an industry.
Definition: tile_type.h:49
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
PC_GRASS_LAND
static const uint8 PC_GRASS_LAND
Dark green palette colour for grass land.
Definition: gfx_func.h:228
newgrf_config.h
ScreenshotFormat::extension
const char * extension
File extension.
Definition: screenshot.cpp:67
Viewport::virtual_top
int virtual_top
Virtual top coordinate.
Definition: viewport_type.h:29
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:52
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
MakeHeightmapScreenshot
bool MakeHeightmapScreenshot(const char *filename)
Make a heightmap of the current map.
Definition: screenshot.cpp:822
InitializeScreenshotFormats
void InitializeScreenshotFormats()
Initialize screenshot format information on startup, with _screenshot_format_name filled from the loa...
Definition: screenshot.cpp:581
textbuf_gui.h
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:372
ai_info.hpp
screenshot.h
gfx_func.h
MapSizeX
static uint MapSizeX()
Get the size of the map along the X.
Definition: map_func.h:72
_confirmed_screenshot_type
static ScreenshotType _confirmed_screenshot_type
Screenshot type the current query is about to confirm.
Definition: screenshot.cpp:835
window_gui.h
height
int height
Height in pixels of our display surface.
Definition: win32_v.cpp:49
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
tile_map.h
_screenshot_name
static char _screenshot_name[128]
Filename of the screenshot file.
Definition: screenshot.cpp:39
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
png_my_error
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
Handle pnglib error.
Definition: splash.cpp:32
Align
static T Align(const T x, uint n)
Return the smallest multiple of n equal or greater than x.
Definition: math_func.hpp:35
TileHeight
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Definition: tile_map.h:29
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:152
SetupScreenshotViewport
void SetupScreenshotViewport(ScreenshotType t, Viewport *vp)
Configure a Viewport for rendering (a part of) the map into a screenshot.
Definition: screenshot.cpp:714
Viewport::virtual_left
int virtual_left
Virtual left coordinate.
Definition: viewport_type.h:28
DEBUG
#define DEBUG(name, level,...)
Output a line of debugging information.
Definition: debug.h:35
_screen_disable_anim
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
Definition: gfx.cpp:43
Viewport::left
int left
Screen coordinate left edge of the viewport.
Definition: viewport_type.h:23
Palette::palette
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
Definition: gfx_type.h:314
FileExists
bool FileExists(const std::string &filename)
Test whether the given filename exists.
Definition: fileio.cpp:280
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
BlitterFactory::GetCurrentBlitter
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition: factory.hpp:131
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:45
safeguards.h
ScreenshotHandlerProc
bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
Function signature for a screenshot generation routine for one of the available formats.
Definition: screenshot.cpp:63
ConstructionSettings::freeform_edges
bool freeform_edges
allow terraforming the tiles at the map edges
Definition: settings_type.h:317
ScreenshotFormat
Screenshot format information.
Definition: screenshot.cpp:66
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
DrawDirtyBlocks
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
Definition: gfx.cpp:1455
ScreenshotCallback
void ScreenshotCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
Callback function signature for generating lines of pixel data to be written to the screenshot file.
Definition: screenshot.cpp:50
_num_screenshot_formats
uint _num_screenshot_formats
Number of available screenshot formats.
Definition: screenshot.cpp:37
CurrentScreenCallback
static void CurrentScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
Callback of the screenshot generator that dumps the current video buffer.
Definition: screenshot.cpp:598
MakeScreenshotName
static const char * MakeScreenshotName(const char *default_fn, const char *ext, bool crashlog=false)
Construct a pathname for a screenshot file.
Definition: screenshot.cpp:668
Viewport::virtual_width
int virtual_width
width << zoom
Definition: viewport_type.h:30
ZOOM_LVL_WORLD_SCREENSHOT
@ ZOOM_LVL_WORLD_SCREENSHOT
Default zoom level for the world screen shot.
Definition: zoom_type.h:41
error.h
MapSizeY
static uint MapSizeY()
Get the size of the map along the Y.
Definition: map_func.h:82
UnScaleByZoom
static int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) When shifting right,...
Definition: zoom_func.h:34
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:204
ZOOM_LVL_VIEWPORT
@ ZOOM_LVL_VIEWPORT
Default zoom level for viewports.
Definition: zoom_type.h:33
landscape.h
BSWAP32
static uint32 BSWAP32(uint32 x)
Perform a 32 bits endianness bitswap on x.
Definition: bitmath_func.hpp:380
ScreenshotFormat::proc
ScreenshotHandlerProc * proc
Function for writing the screenshot.
Definition: screenshot.cpp:68
viewport_func.h
Blitter::CopyImageToBuffer
virtual void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)=0
Copy from the screen to a buffer in a palette format for 8bpp and RGBA format for 32bpp.
PACK
PACK(struct BitmapFileHeader { uint16 type;uint32 size;uint32 reserved;uint32 off_bits;})
BMP File Header (stored in little endian)
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
GenerateDefaultSaveName
void GenerateDefaultSaveName(char *buf, const char *last)
Fill the buffer with the default name for a savegame or screenshot.
Definition: saveload.cpp:2861
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:178
Colour
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Definition: gfx_type.h:163
GUISettings::zoom_min
ZoomLevel zoom_min
minimum zoom out level
Definition: settings_type.h:109
LargeWorldCallback
static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
generate a large piece of the world
Definition: screenshot.cpp:613
_screenshot_formats
static const ScreenshotFormat _screenshot_formats[]
Available screenshot formats.
Definition: screenshot.cpp:566
ShowQuery
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1274
rev.h
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
Pool::PoolItem<&_company_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:378
MakeBMPImage
static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
Generic .BMP writer.
Definition: screenshot.cpp:113
strings_func.h
ScaleByZoom
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right,...
Definition: zoom_func.h:22
SC_WORLD
@ SC_WORLD
World screenshot.
Definition: screenshot.h:23
MakePCXImage
static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
Generic .PCX file image writer.
Definition: screenshot.cpp:436
HEIGHTMAP_NAME
static const char *const HEIGHTMAP_NAME
Default filename of a saved heightmap.
Definition: screenshot.cpp:34
Colour::a
uint8 a
colour channels in LE order
Definition: gfx_type.h:171
MP_VOID
@ MP_VOID
Invisible tiles at the SW and SE border.
Definition: tile_type.h:48
Blitter::MoveTo
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
TileXY
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
Definition: map_func.h:163
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
GRFConfig::next
struct GRFConfig * next
NOSAVE: Next item in the linked list.
Definition: newgrf_config.h:177
OWNER_NONE
@ OWNER_NONE
The tile has no ownership.
Definition: company_type.h:25
width
int width
Width in pixels of our display surface.
Definition: win32_v.cpp:48
MakePNGImage
static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
Generic .PNG file image writer.
Definition: screenshot.cpp:259
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:442
SC_DEFAULTZOOM
@ SC_DEFAULTZOOM
Zoomed to default zoom level screenshot of the visible area.
Definition: screenshot.h:22
OWNER_DEITY
@ OWNER_DEITY
The object is owned by a superuser / goal script.
Definition: company_type.h:27
WC_MAIN_WINDOW
@ WC_MAIN_WINDOW
Main window; Window numbers:
Definition: window_type.h:44
_screenshot_format_name
char _screenshot_format_name[8]
Extension of the current screenshot format (corresponds with _cur_screenshot_format).
Definition: screenshot.cpp:36
MakeSmallScreenshot
static bool MakeSmallScreenshot(bool crashlog)
Make a screenshot of the current screen.
Definition: screenshot.cpp:702
company_func.h
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:24
_full_screenshot_name
char _full_screenshot_name[MAX_PATH]
Pathname of the screenshot file.
Definition: screenshot.cpp:40
MapMaxX
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
Definition: map_func.h:102
PC_WATER
static const uint8 PC_WATER
Dark blue palette colour for water.
Definition: gfx_func.h:233
MakeMinimapWorldScreenshot
bool MakeMinimapWorldScreenshot()
Make a minimap screenshot.
Definition: screenshot.cpp:1002
TILE_ADDXY
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
Definition: map_func.h:258
_cur_palette
Palette _cur_palette
Current palette.
Definition: gfx.cpp:48
_grfconfig
GRFConfig * _grfconfig
First item in list of current GRF set up.
Definition: newgrf_config.cpp:170
_cur_screenshot_format
uint _cur_screenshot_format
Index of the currently selected screenshot format in _screenshot_formats.
Definition: screenshot.cpp:38
window_func.h
GetCurrentScreenshotExtension
const char * GetCurrentScreenshotExtension()
Get filename extension of current screenshot file format.
Definition: screenshot.cpp:575
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:377
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
png_my_warning
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
Handle warning in pnglib.
Definition: splash.cpp:44
MakeLargeWorldScreenshot
static bool MakeLargeWorldScreenshot(ScreenshotType t)
Make a screenshot of the map.
Definition: screenshot.cpp:783
SC_VIEWPORT
@ SC_VIEWPORT
Screenshot of viewport.
Definition: screenshot.h:19
MakeScreenshotWithConfirm
void MakeScreenshotWithConfirm(ScreenshotType t)
Make a screenshot.
Definition: screenshot.cpp:853
OWNER_END
@ OWNER_END
Last + 1 owner.
Definition: company_type.h:28
GameSettings::construction
ConstructionSettings construction
construction of things in-game
Definition: settings_type.h:549
Window
Data structure for an opened window.
Definition: window_gui.h:276
md5sumToString
char * md5sumToString(char *buf, const char *last, const uint8 md5sum[16])
Convert the md5sum to a hexadecimal string representation.
Definition: string.cpp:460
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
SC_CRASHLOG
@ SC_CRASHLOG
Raw screenshot from blitter buffer.
Definition: screenshot.h:20
BaseMedia< GraphicsSet >::GetUsedSet
static const GraphicsSet * GetUsedSet()
Return the used set.
Definition: base_media_func.h:357
PC_DARK_GREY
static const uint8 PC_DARK_GREY
Dark grey palette colour.
Definition: gfx_func.h:205
Viewport::virtual_height
int virtual_height
height << zoom
Definition: viewport_type.h:31
SC_MINIMAP
@ SC_MINIMAP
Minimap screenshot.
Definition: screenshot.h:25
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
MakeScreenshot
bool MakeScreenshot(ScreenshotType t, const char *name)
Make a screenshot.
Definition: screenshot.cpp:882
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:469
SCREENSHOT_NAME
static const char *const SCREENSHOT_NAME
Default filename of a saved screenshot.
Definition: screenshot.cpp:33
Company
Definition: company_base.h:110
OWNER_WATER
@ OWNER_WATER
The tile/execution is done by "water".
Definition: company_type.h:26
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:393
OWNER_TOWN
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
Definition: company_type.h:24
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:286
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:565
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:155
FiosGetScreenshotDir
const char * FiosGetScreenshotDir()
Get the directory for screenshots.
Definition: fios.cpp:624
ScreenshotConfirmationCallback
static void ScreenshotConfirmationCallback(Window *w, bool confirmed)
Callback on the confirmation window for huge screenshots.
Definition: screenshot.cpp:842
AllocaM
#define AllocaM(T, num_elements)
alloca() has to be called in the parent function, so define AllocaM() as a macro
Definition: alloc_func.hpp:132