Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 205707
Collapse All | Expand All

(-)a/.gitignore (+19 lines)
Line 0 Link Here
1
*.o
2
lib*.a
3
made.tmp
4
res/sim
5
src/tclx/runtcl
6
src/tclx/runwish
7
src/tclx/src/tclxgdat.c
8
src/tclx/tcl
9
src/tclx/tcldef
10
src/tclx/tcllib/tcl.tlb
11
src/tclx/tcllib/tk.tcl
12
src/tclx/tcllib/wishx.tcl
13
src/tclx/tkucbsrc/main.c
14
src/tclx/tkucbsrc/tkevent.c
15
src/tclx/ucbsrc/tclbasic.c
16
src/tclx/ucbsrc/tclexpr.c
17
src/tclx/wish
18
src/tk/wish
19
src/sim/sim
(-)a/Makefile (+124 lines)
Line 0 Link Here
1
PREFIX=/usr/local
2
DATADIR=$(PREFIX)/share/micropolis
3
LIBEXECDIR=$(PREFIX)/libexec
4
BINDIR=$(PREFIX)/bin
5
DOCDIR=$(PREFIX)/share/doc/micropolis
6
PIXMAPDIR=$(PREFIX)/share/pixmaps
7
APPLICATIONSDIR=$(PREFIX)/share/applications
8
9
INSTALL=install
10
11
DIRS=	$(DESTDIR)/$(DATADIR)/res/sounds $(DESTDIR)/$(DATADIR)/res/dejavu-lgc \
12
	$(DESTDIR)/$(DATADIR)/images $(DESTDIR)/$(DATADIR)/cities \
13
	$(DESTDIR)/$(LIBEXECDIR) $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(DOCDIR) \
14
	$(DESTDIR)/$(PIXMAPDIR) $(DESTDIR)/$(APPLICATIONSDIR)
15
16
RES=	res/buildidx.tcl res/button.tcl res/entry.tcl res/help.tcl res/hexa.112 \
17
	res/hexa.232 res/hexa.384 res/hexa.385 res/hexa.386 res/hexa.387 \
18
	res/hexa.388 res/hexa.456 res/hexa.544 res/hexa.563 res/hexa.999 \
19
	res/init.tcl res/listbox.tcl res/menu.tcl res/micropolis.tcl \
20
	res/mkindex.tcl res/parray.tcl res/snro.111 res/snro.222 res/snro.333 \
21
	res/snro.444 res/snro.555 res/snro.666 res/snro.777 res/snro.888 \
22
	res/sound.tcl res/stri.202 res/stri.219 res/stri.301 res/stri.356 \
23
	res/tcl.tdx res/tcl.tlb res/tclindex res/tclinit.tcl res/text.tcl \
24
	res/tk.tcl res/tk.tdx res/tk.tlb res/tkerror.tcl res/wask.tcl \
25
	res/wbudget.tcl res/weditor.tcl res/weval.tcl res/wfile.tcl \
26
	res/wfrob.tcl res/wgraph.tcl res/whead.tcl res/whelp.tcl res/wish.tcl \
27
	res/wishx.tcl res/wmap.tcl res/wnotice.tcl res/wplayer.tcl \
28
	res/wscen.tcl res/wsplash.tcl
29
30
all: res/sim
31
32
res/sim: src/sim/sim
33
	cp src/sim/sim $@
34
	strip $@
35
36
src/sim/sim: tcl tk tclx sim
37
	@#
38
39
tcl:
40
	cd src/tcl && $(MAKE) MAKEFLAGS=
41
42
tk:
43
	cd src/tk && $(MAKE) MAKEFLAGS=
44
45
tclx:
46
	cd src/tclx && $(MAKE) MAKEFLAGS=
47
48
sim:
49
	cd src/sim && $(MAKE) MAKEFLAGS=
50
51
clean: 
52
	cd src/sim && $(MAKE) MAKEFLAGS= $@
53
	cd src/tcl && $(MAKE) MAKEFLAGS= $@
54
	cd src/tk && $(MAKE) MAKEFLAGS= $@
55
	cd src/tclx && $(MAKE) MAKEFLAGS= $@
56
	rm -f res/sim
57
58
install: res/sim install-dirs install-bin install-res install-images \
59
	install-cities install-doc install-desktop
60
61
install-dirs:
62
	$(INSTALL) -d $(DIRS)
63
64
install-bin:
65
	$(INSTALL) -m 0755 res/sim $(DESTDIR)/$(LIBEXECDIR)/sim
66
	$(INSTALL) -m 0755 res/sounds/player $(DESTDIR)/$(DATADIR)/res/sounds/player
67
	echo "SIMHOME=$(DATADIR); export SIMHOME" >$(DESTDIR)/$(BINDIR)/micropolis
68
	echo "echo \"Starting Micropolis in \$${SIMHOME} ... \"" >>$(DESTDIR)/$(BINDIR)/micropolis
69
	echo "cd $(DATADIR) && $(LIBEXECDIR)/sim \$$*" >>$(DESTDIR)/$(BINDIR)/micropolis
70
	chmod 755 $(DESTDIR)/$(BINDIR)/micropolis
71
72
install-res: install-res-sounds install-res-dejavu-lgc
73
	for file in $(RES); do \
74
		install -m 0644 $$file $(DESTDIR)/$(DATADIR)/$$file; \
75
	done
76
77
install-res-sounds:
78
	find res/sounds -type f -name \*.wav -exec $(INSTALL) -m 0644 {} $(DESTDIR)/$(DATADIR)/res/sounds/ \;
79
80
install-res-dejavu-lgc:
81
	find res/dejavu-lgc -type f -exec $(INSTALL) -m 0644 {} $(DESTDIR)/$(DATADIR)/res/dejavu-lgc/ \;
82
83
install-images:
84
	find images -type f -exec $(INSTALL) -m 0644 {} $(DESTDIR)/$(DATADIR)/images/ \;
85
86
install-cities:
87
	find cities -type f -exec $(INSTALL) -m 0644 {} $(DESTDIR)/$(DATADIR)/cities/ \;
88
89
install-doc:
90
	find manual -type f -exec $(INSTALL) -m 0644 {} $(DESTDIR)/$(DOCDIR)/ \;
91
92
install-desktop:
93
	$(INSTALL) -m 0644 Micropolis.desktop $(DESTDIR)/$(APPLICATIONSDIR)/micropolis.desktop
94
	$(INSTALL) -m 0644 Micropolis.png $(DESTDIR)/$(PIXMAPDIR)/micropolis.png
95
96
uninstall:
97
	rm -f $(DESTDIR)/$(BINDIR)/micropolis
98
	rm -f $(DESTDIR)/$(LIBEXECDIR)/sim
99
	-rmdir $(DESTDIR)/$(LIBEXECDIR)
100
	rm -f $(DESTDIR)/$(DATADIR)/res/sounds/player
101
	rm -f $(DESTDIR)/$(DATADIR)/res/sounds/*.wav
102
	-rmdir $(DESTDIR)/$(DATADIR)/res/sounds
103
	rm -f $(DESTDIR)/$(DATADIR)/res/dejavu-lgc/*ttf \
104
		$(DESTDIR)/$(DATADIR)/res/dejavu-lgc/fonts.alias \
105
		$(DESTDIR)/$(DATADIR)/res/dejavu-lgc/fonts.dir \
106
		$(DESTDIR)/$(DATADIR)/res/dejavu-lgc/fonts.scale
107
	-rmdir $(DESTDIR)/$(DATADIR)/res/dejavu-lgc
108
	for file in $(RES); do \
109
		rm $(DESTDIR)/$(DATADIR)/$$file; \
110
	done
111
	-rmdir $(DESTDIR)/$(DATADIR)/res
112
	rm -f $(DESTDIR)/$(DATADIR)/images/*.xpm
113
	-rmdir $(DESTDIR)/$(DATADIR)/images
114
	rm -f $(DESTDIR)/$(DATADIR)/cities/*.cty
115
	-rmdir $(DESTDIR)/$(DATADIR)/cities
116
	-rmdir $(DESTDIR)/$(DATADIR)
117
	rm -f $(DESTDIR)/$(DOCDIR)/*.html $(DESTDIR)/$(DOCDIR)/README
118
	-rmdir $(DESTDIR)/$(DOCDIR)
119
	rm -f $(DESTDIR)/$(APPLICATIONSDIR)/micropolis.desktop
120
	rm -f $(DESTDIR)/$(PIXMAPDIR)/micropolis.png
121
122
.PHONY: all clean install install-dirs install-bin install-res \
123
	install-res-sounds install-res-dejavu-lgc install-images \
124
	install-cities install-doc install-desktop uninstall tcl tk tclx sim
(-)a/Micropolis.desktop (+12 lines)
Line 0 Link Here
1
[Desktop Entry]
2
Type=Application
3
Version=1.0
4
Encoding=UTF-8
5
Name=Micropolis
6
GenericName=Micropolis City Simulation Game
7
Comment=City simulation game, open sourced from original SimCity(tm)
8
Icon=micropolis.png
9
Exec=micropolis
10
Terminal=false
11
StartupNotify=false
12
Categories=Game;Simulation;
(-)a/res/micropolis.tcl (-17 / +57 lines)
Lines 97-102 set DemandCom 0 Link Here
97
set DemandInd 0
97
set DemandInd 0
98
set Priority 2
98
set Priority 2
99
set Time 3
99
set Time 3
100
set Pause 0
100
set AutoGoto 1
101
set AutoGoto 1
101
set AutoBudget 1
102
set AutoBudget 1
102
set Disasters 1
103
set Disasters 1
Lines 412-419 sim ResetDynamic Link Here
412
# the font in res (because it's already in the system fonts).  These lines
413
# the font in res (because it's already in the system fonts).  These lines
413
# are for other systems that lack the font.
414
# are for other systems that lack the font.
414
set FontPath "[pwd]/res/dejavu-lgc"
415
set FontPath "[pwd]/res/dejavu-lgc"
415
system "xset -fp $FontPath >&/dev/null"
416
system "xset -fp \"$FontPath\" >/dev/null 2>&1"
416
system "xset +fp $FontPath >&/dev/null"
417
system "xset +fp \"$FontPath\" >/dev/null 2>&1"
417
418
418
419
419
########################################################################
420
########################################################################
Lines 484-490 Either clean up your act or open a gas mask concession at city hall.} \ Link Here
484
{{view {PanView $v [sim PolMaxX] [sim PolMaxY]}}}
485
{{view {PanView $v [sim PolMaxX] [sim PolMaxY]}}}
485
486
486
Message 11 #ff4f4f {CRIME ALERT!} \
487
Message 11 #ff4f4f {CRIME ALERT!} \
487
{Crime in your city is our of hand.  Angry mobs are looting and vandalizing the central city.  The president will send in the national guard soon if you cannot control the problem.} \
488
{Crime in your city is out of hand.  Angry mobs are looting and vandalizing the central city.  The president will send in the national guard soon if you cannot control the problem.} \
488
{{view {PanView $v [sim CrimeMaxX] [sim CrimeMaxY]}}}
489
{{view {PanView $v [sim CrimeMaxX] [sim CrimeMaxY]}}}
489
490
490
Message 12 #ff4f4f {TRAFFIC WARNING!} \
491
Message 12 #ff4f4f {TRAFFIC WARNING!} \
Lines 938-946 proc UISetChannelVolume {win chan vol} { Link Here
938
939
939
proc EchoPlaySound {soundspec} {
940
proc EchoPlaySound {soundspec} {
940
  # Temporary workaround to tell Python Sugar app to play sound.
941
  # Temporary workaround to tell Python Sugar app to play sound.
941
  global Sound
942
  global Sound ResourceDir
942
  if {$Sound} {
943
  if {$Sound} {
943
    echo PlaySound [lindex $soundspec 0]
944
    #echo PlaySound [lindex $soundspec 0]
945
    signal ignore SIGCHLD
946
    exec "${ResourceDir}/sounds/player" "${ResourceDir}/sounds/[string tolower [lindex $soundspec 0]].wav" &
944
  }
947
  }
945
}
948
}
946
949
Lines 2041-2053 proc DoFileDialog {win Message Path Pattern FileName ActionOk ActionCancel} { Link Here
2041
      wm withdraw $win"
2044
      wm withdraw $win"
2042
  bind $win.files.files "<Double-Button-1>" "\
2045
  bind $win.files.files "<Double-Button-1>" "\
2043
    FileSelectDouble $win %W %y $Pattern \"
2046
    FileSelectDouble $win %W %y $Pattern \"
2044
	$ActionOk \[$win.file.file get\] \[$win.path.path get\]\""
2047
	$ActionOk {\[$win.file.file get\]} {\[$win.path.path get\]}\""
2045
  bind $win.path.path <Return> "
2048
  bind $win.path.path <Return> "
2046
    ShowFileDialog $win \[$win.path.path get\] $Pattern
2049
    ShowFileDialog $win \[$win.path.path get\] $Pattern
2047
    $win.file.file cursor 0
2050
    $win.file.file cursor 0
2048
    focus $win.file.file"
2051
    focus $win.file.file"
2049
  bind $win.file.file <Return> "\
2052
  bind $win.file.file <Return> "\
2050
    $ActionOk \[$win.file.file get\] \[$win.path.path get]
2053
    $ActionOk \[$win.file.file get\] \[$win.path.path get\]
2051
    wm withdraw $win"
2054
    wm withdraw $win"
2052
}
2055
}
2053
2056
Lines 2283-2300 proc NameComplete {win Type} { Link Here
2283
2286
2284
proc ShowFileDialog {win Path Pattern} {
2287
proc ShowFileDialog {win Path Pattern} {
2285
  busy $win {
2288
  busy $win {
2286
    set Path [lindex [split $Path] 0]
2289
    #set Path [lindex [split $Path] 0]
2287
    if {[$win.files.files size] > 0} {
2290
    if {[$win.files.files size] > 0} {
2288
      $win.files.files delete 0 end
2291
      $win.files.files delete 0 end
2289
    }
2292
    }
2290
    # read directory
2293
    # read directory
2291
    if {[catch "exec ls -F $Path" Result]} {
2294
    if {[catch "exec ls -F \"$Path\"" Result]} {
2292
      set ElementList {}
2295
      set ElementList {}
2293
    }
2296
    }
2294
    if {[string match $Result "* not found"]} {
2297
    if {[string match $Result "* not found"]} {
2295
      set ElementList {}
2298
      set ElementList {}
2296
    }
2299
    }
2297
    set ElementList [lsort $Result]
2300
    set ElementList [lsort [split $Result "\n"]]
2298
2301
2299
    # insert ..
2302
    # insert ..
2300
    if {[string compare $Path "/"]} {
2303
    if {[string compare $Path "/"]} {
Lines 3099-3106 proc ShowSplashOf {head} { Link Here
3099
3102
3100
3103
3101
proc WithdrawSplashOf {head} {
3104
proc WithdrawSplashOf {head} {
3102
  set win WindowLink $head.splash]
3105
  set win [WindowLink $head.splash]
3103
  wm withdraw $win
3106
  if {$win != {}} {
3107
    wm withdraw $win
3108
  }
3104
}
3109
}
3105
3110
3106
3111
Lines 3150-3157 proc ShowScenarioOf {head} { Link Here
3150
3155
3151
3156
3152
proc WithdrawScenarioOf {head} {
3157
proc WithdrawScenarioOf {head} {
3153
  set win WindowLink $head.scenario]
3158
  set win [WindowLink $head.scenario]
3154
  wm withdraw $win
3159
  if {$win != {}} {
3160
    wm withdraw $win
3161
  }
3155
}
3162
}
3156
3163
3157
3164
Lines 3303-3314 proc UpdateScenarioButtonID {win id} { Link Here
3303
3310
3304
3311
3305
proc UpdateScenarioButton {win data} {
3312
proc UpdateScenarioButton {win data} {
3313
  global Messages
3314
3306
  set type [lindex $data 0]
3315
  set type [lindex $data 0]
3307
  set id [lindex $data 1]
3316
  set id [lindex $data 1]
3308
  set over [WindowLink $win.$id.over]
3317
  set over [WindowLink $win.$id.over]
3309
  set enabled [WindowLink $win.$id.enabled]
3318
  set enabled [WindowLink $win.$id.enabled]
3310
  set checked [WindowLink $win.$id.checked]
3319
  set checked [WindowLink $win.$id.checked]
3311
  #echo "WIN $win TYPE $type ID $id OVER $over ENABLED $enabled CHECKED $checked"
3320
  #echo "WIN $win TYPE $type ID $id OVER $over ENABLED $enabled CHECKED $checked"
3321
  if {$over} {
3322
    if {[lindex ${data} 2] == "DoPickScenario"} {
3323
      catch {text $win.desc \
3324
      	-borderwidth 2 \
3325
      	-relief flat \
3326
      	-wrap word \
3327
      	-state normal \
3328
      	-font [Font $win Large]}
3329
      
3330
      $win.desc configure -state normal
3331
      $win.desc delete 0.0 end
3332
      $win.desc insert end "[lindex $Messages([lindex ${data} 3]) 1]\n\n[lindex $Messages([lindex ${data} 3]) 2]"
3333
      $win.desc configure -state disabled
3334
      
3335
      place $win.desc -x 232 -y 170 -width 280 -height 285
3336
    }
3337
  } else {
3338
    catch {destroy $win.desc}
3339
  }
3312
  if {$enabled} {
3340
  if {$enabled} {
3313
    if {$checked} {
3341
    if {$checked} {
3314
      if {$over} {
3342
      if {$over} {
Lines 3542-3547 proc DoPickScenario {win param} { Link Here
3542
  UILoadScenario $param
3570
  UILoadScenario $param
3543
}
3571
}
3544
3572
3573
proc DeleteScenarioWindow {win} {
3574
  UIQuit $win
3575
}
3576
3545
3577
3546
########################################################################
3578
########################################################################
3547
# Undo/Redo Facility
3579
# Undo/Redo Facility
Lines 4907-4918 proc oops {} { Link Here
4907
4939
4908
4940
4909
proc TogglePause {} {
4941
proc TogglePause {} {
4910
  global State
4942
  global State Pause
4911
4943
4912
  if {"$State" != "play" || [sim Speed]} {
4944
  if {"$State" != "play" || [sim Speed]} {
4913
    sim Speed 0
4945
    sim Speed 0
4946
    set Pause 1
4914
  } else {
4947
  } else {
4915
    sim Speed 3
4948
    sim Speed 3
4949
    set Pause 0
4916
  }
4950
  }
4917
  MakeRunningSound
4951
  MakeRunningSound
4918
}
4952
}
Lines 5119-5125 proc UIDoLoadCity {name path} { Link Here
5119
  if {![string match *.cty $name]} {
5153
  if {![string match *.cty $name]} {
5120
    set name $name.cty
5154
    set name $name.cty
5121
  }
5155
  }
5122
  MakeHistory "DoLoadCity $path/$name"
5156
  MakeHistory "DoLoadCity {$path/$name}"
5123
}
5157
}
5124
5158
5125
5159
Lines 5214-5221 proc DoLeaveGame {head} { Link Here
5214
5248
5215
5249
5216
proc UILoseGame {} {
5250
proc UILoseGame {} {
5217
  UIPickScenarioMode
5251
  global Messages
5218
  UIShowPicture 200
5252
  UIShowPicture 200
5253
  sim Pause
5254
  AskQuestion [Color . #ff0000 #ffffff] [lindex $Messages(200) 1] \
5255
    [lindex $Messages(200) 2] \
5256
    ""\
5257
    ""\
5258
    "{Ok} SelectCity.Yes {UIPickScenarioMode}"
5219
}
5259
}
5220
5260
5221
5261
(-)a/res/sounds/player (+25 lines)
Line 0 Link Here
1
#!/bin/bash
2
3
PLAYER=
4
5
if type -a aplay &>/dev/null; then
6
	PLAYER=aplay
7
elif type -a afplay &>/dev/null; then
8
	#afplay is shipped with OS X Leopard
9
	PLAYER=afplay
10
elif type -a play &>/dev/null; then
11
	PLAYER=play
12
elif type -a mplayer &>/dev/null; then
13
	PLAYER="mplayer -nogui -nocache"
14
fi
15
16
if [ "x${PLAYER}" = "x" ]; then
17
	echo "Can't find audio player!"
18
	echo "Please make sure you have aplay, play or mplayer in your path."
19
	if [ "`uname`" = "Darwin" ]; then
20
		echo "A working play for OS X is available from:"
21
		echo "http://www.hieper.nl/html/play.html"
22
	fi
23
else
24
	exec ${PLAYER} "$@" >/dev/null 2>&1
25
fi
(-)a/res/weditor.tcl (-4 / +4 lines)
Lines 120-126 if {0} { Link Here
120
    -relief flat
120
    -relief flat
121
  tk_bindForTraversal $win.topframe.controls.update
121
  tk_bindForTraversal $win.topframe.controls.update
122
  bind $win.topframe.controls.update <F10> {tk_firstMenu %W} 
122
  bind $win.topframe.controls.update <F10> {tk_firstMenu %W} 
123
  bind $win.topframe.controls.update <Mod2-Key> {tk_traverseToMenu %W %A} 
123
  bind $win.topframe.controls.update <Alt-Key> {tk_traverseToMenu %W %A} 
124
  tk_menus $win $win.topframe.controls.update
124
  tk_menus $win $win.topframe.controls.update
125
125
126
  SetHelp $win.topframe.controls.update Editor.Display
126
  SetHelp $win.topframe.controls.update Editor.Display
Lines 129-135 if {0} { Link Here
129
    -font [Font $win Medium]
129
    -font [Font $win Medium]
130
  tk_bindForTraversal $win.topframe.controls.update.m
130
  tk_bindForTraversal $win.topframe.controls.update.m
131
  bind $win.topframe.controls.update.m <F10> {tk_firstMenu %W} 
131
  bind $win.topframe.controls.update.m <F10> {tk_firstMenu %W} 
132
  bind $win.topframe.controls.update.m <Mod2-Key> {tk_traverseToMenu %W %A} 
132
  bind $win.topframe.controls.update.m <Alt-Key> {tk_traverseToMenu %W %A} 
133
    $win.topframe.controls.update.m add radiobutton\
133
    $win.topframe.controls.update.m add radiobutton\
134
      -label {Always}\
134
      -label {Always}\
135
      -variable Skip.$win\
135
      -variable Skip.$win\
Lines 166-172 menubutton $win.topframe.controls.options\ Link Here
166
  -relief flat
166
  -relief flat
167
tk_bindForTraversal $win.topframe.controls.options
167
tk_bindForTraversal $win.topframe.controls.options
168
bind $win.topframe.controls.options <F10> {tk_firstMenu %W} 
168
bind $win.topframe.controls.options <F10> {tk_firstMenu %W} 
169
bind $win.topframe.controls.options <Mod2-Key> {tk_traverseToMenu %W %A} 
169
bind $win.topframe.controls.options <Alt-Key> {tk_traverseToMenu %W %A} 
170
tk_menus $win $win.topframe.controls.options
170
tk_menus $win $win.topframe.controls.options
171
171
172
SetHelp $win.topframe.controls.options Editor.Options
172
SetHelp $win.topframe.controls.options Editor.Options
Lines 175-181 menu $win.topframe.controls.options.m\ Link Here
175
  -font [Font $win Medium]
175
  -font [Font $win Medium]
176
tk_bindForTraversal $win.topframe.controls.options.m
176
tk_bindForTraversal $win.topframe.controls.options.m
177
bind $win.topframe.controls.options.m <F10> {tk_firstMenu %W} 
177
bind $win.topframe.controls.options.m <F10> {tk_firstMenu %W} 
178
bind $win.topframe.controls.options.m <Mod2-Key> {tk_traverseToMenu %W %A} 
178
bind $win.topframe.controls.options.m <Alt-Key> {tk_traverseToMenu %W %A} 
179
$win.topframe.controls.options.m add checkbutton\
179
$win.topframe.controls.options.m add checkbutton\
180
  -label {Auto Goto}\
180
  -label {Auto Goto}\
181
  -variable AutoGoto.$win\
181
  -variable AutoGoto.$win\
(-)a/res/whead.tcl (-25 / +52 lines)
Lines 78-87 global NoticePanelHeight Link Here
78
78
79
set visual [winfo screenvisual $win]
79
set visual [winfo screenvisual $win]
80
set depth [winfo screendepth $win]
80
set depth [winfo screendepth $win]
81
#set screenwidth [winfo screenwidth $win]
81
set screenwidth [winfo screenwidth $win]
82
#set screenheight [winfo screenheight $win]
82
set screenheight [winfo screenheight $win]
83
set screenwidth 1200
83
set initialwidth 1200
84
set screenheight 900
84
set initialheight 900
85
86
if {$screenwidth < $initialwidth} {
87
	set initialwidth $screenwidth
88
}
89
90
if {$screenheight < $initialheight} {
91
	set initialheight $screenheight
92
}
93
85
94
86
if {!(("$visual" == "pseudocolor") ||
95
if {!(("$visual" == "pseudocolor") ||
87
      ("$visual" == "truecolor") ||
96
      ("$visual" == "truecolor") ||
Lines 112-126 LinkWindow $win.ask {} Link Here
112
121
113
tk_bindForTraversal $win
122
tk_bindForTraversal $win
114
bind $win <F10> {tk_firstMenu %W} 
123
bind $win <F10> {tk_firstMenu %W} 
115
bind $win <Mod2-Key> {tk_traverseToMenu %W %A} 
124
bind $win <Alt-Key> {tk_traverseToMenu %W %A} 
116
125
117
wm title $win "Micropolis Controls"
126
wm title $win "Micropolis Controls"
118
wm iconname $win {Micropolis Controls}
127
wm iconname $win {Micropolis Controls}
119
wm geometry $win 1200x900+0+0
128
wm geometry $win ${initialwidth}x${initialheight}+0+0
120
#wm positionfrom $win user
129
#wm positionfrom $win user
121
wm withdraw $win
130
wm withdraw $win
122
#wm maxsize $win $screenwidth $screenheight
131
wm maxsize $win $screenwidth $screenheight
123
#wm minsize $win 100 100
132
wm minsize $win 100 100
124
wm protocol $win delete "DeleteHeadWindow $win ;"
133
wm protocol $win delete "DeleteHeadWindow $win ;"
125
wm fullscreen $win on
134
wm fullscreen $win on
126
135
Lines 142-148 frame $win.col1.w1.f1\ Link Here
142
  -relief raised
151
  -relief raised
143
tk_bindForTraversal $win.col1.w1.f1
152
tk_bindForTraversal $win.col1.w1.f1
144
bind $win.col1.w1.f1 <F10> {tk_firstMenu %W} 
153
bind $win.col1.w1.f1 <F10> {tk_firstMenu %W} 
145
bind $win.col1.w1.f1 <Mod2-Key> {tk_traverseToMenu %W %A} 
154
bind $win.col1.w1.f1 <Alt-Key> {tk_traverseToMenu %W %A} 
146
155
147
SetHelp $win.col1.w1.f1.micropolis Head.MicropolisMenu
156
SetHelp $win.col1.w1.f1.micropolis Head.MicropolisMenu
148
157
Lines 153-159 menubutton $win.col1.w1.f1.micropolis\ Link Here
153
  -variable $win.postedMenu
162
  -variable $win.postedMenu
154
tk_bindForTraversal $win.col1.w1.f1.micropolis
163
tk_bindForTraversal $win.col1.w1.f1.micropolis
155
bind $win.col1.w1.f1.micropolis <F10> {tk_firstMenu %W} 
164
bind $win.col1.w1.f1.micropolis <F10> {tk_firstMenu %W} 
156
bind $win.col1.w1.f1.micropolis <Mod2-Key> {tk_traverseToMenu %W %A} 
165
bind $win.col1.w1.f1.micropolis <Alt-Key> {tk_traverseToMenu %W %A} 
157
166
158
tk_menus $win $win.col1.w1.f1.micropolis
167
tk_menus $win $win.col1.w1.f1.micropolis
159
168
Lines 161-167 menu $win.col1.w1.f1.micropolis.m\ Link Here
161
  -font [Font $win Medium]
170
  -font [Font $win Medium]
162
tk_bindForTraversal $win.col1.w1.f1.micropolis.m
171
tk_bindForTraversal $win.col1.w1.f1.micropolis.m
163
bind $win.col1.w1.f1.micropolis.m <F10> {tk_firstMenu %W} 
172
bind $win.col1.w1.f1.micropolis.m <F10> {tk_firstMenu %W} 
164
bind $win.col1.w1.f1.micropolis.m <Mod2-Key> {tk_traverseToMenu %W %A} 
173
bind $win.col1.w1.f1.micropolis.m <Alt-Key> {tk_traverseToMenu %W %A} 
165
  $win.col1.w1.f1.micropolis.m add command\
174
  $win.col1.w1.f1.micropolis.m add command\
166
    -label {About...}\
175
    -label {About...}\
167
    -command "UIShowPicture 300"
176
    -command "UIShowPicture 300"
Lines 192-198 menubutton $win.col1.w1.f1.options\ Link Here
192
  -variable $win.postedMenu
201
  -variable $win.postedMenu
193
tk_bindForTraversal $win.col1.w1.f1.options
202
tk_bindForTraversal $win.col1.w1.f1.options
194
bind $win.col1.w1.f1.options <F10> {tk_firstMenu %W} 
203
bind $win.col1.w1.f1.options <F10> {tk_firstMenu %W} 
195
bind $win.col1.w1.f1.options <Mod2-Key> {tk_traverseToMenu %W %A} 
204
bind $win.col1.w1.f1.options <Alt-Key> {tk_traverseToMenu %W %A} 
196
205
197
tk_menus $win $win.col1.w1.f1.options
206
tk_menus $win $win.col1.w1.f1.options
198
207
Lines 200-206 menu $win.col1.w1.f1.options.m\ Link Here
200
  -font [Font $win Medium]
209
  -font [Font $win Medium]
201
tk_bindForTraversal $win.col1.w1.f1.options.m
210
tk_bindForTraversal $win.col1.w1.f1.options.m
202
bind $win.col1.w1.f1.options.m <F10> {tk_firstMenu %W} 
211
bind $win.col1.w1.f1.options.m <F10> {tk_firstMenu %W} 
203
bind $win.col1.w1.f1.options.m <Mod2-Key> {tk_traverseToMenu %W %A} 
212
bind $win.col1.w1.f1.options.m <Alt-Key> {tk_traverseToMenu %W %A} 
204
  $win.col1.w1.f1.options.m add checkbutton\
213
  $win.col1.w1.f1.options.m add checkbutton\
205
    -label {Auto Budget}\
214
    -label {Auto Budget}\
206
    -variable AutoBudget\
215
    -variable AutoBudget\
Lines 239-245 menubutton $win.col1.w1.f1.disasters\ Link Here
239
  -variable $win.postedMenu
248
  -variable $win.postedMenu
240
tk_bindForTraversal $win.col1.w1.f1.disasters
249
tk_bindForTraversal $win.col1.w1.f1.disasters
241
bind $win.col1.w1.f1.disasters <F10> {tk_firstMenu %W} 
250
bind $win.col1.w1.f1.disasters <F10> {tk_firstMenu %W} 
242
bind $win.col1.w1.f1.disasters <Mod2-Key> {tk_traverseToMenu %W %A} 
251
bind $win.col1.w1.f1.disasters <Alt-Key> {tk_traverseToMenu %W %A} 
243
252
244
tk_menus $win $win.col1.w1.f1.disasters
253
tk_menus $win $win.col1.w1.f1.disasters
245
254
Lines 247-253 menu $win.col1.w1.f1.disasters.m\ Link Here
247
  -font [Font $win Medium]
256
  -font [Font $win Medium]
248
tk_bindForTraversal $win.col1.w1.f1.disasters.m
257
tk_bindForTraversal $win.col1.w1.f1.disasters.m
249
bind $win.col1.w1.f1.disasters.m <F10> {tk_firstMenu %W} 
258
bind $win.col1.w1.f1.disasters.m <F10> {tk_firstMenu %W} 
250
bind $win.col1.w1.f1.disasters.m <Mod2-Key> {tk_traverseToMenu %W %A} 
259
bind $win.col1.w1.f1.disasters.m <Alt-Key> {tk_traverseToMenu %W %A} 
251
  $win.col1.w1.f1.disasters.m add command\
260
  $win.col1.w1.f1.disasters.m add command\
252
    -label {Monster}\
261
    -label {Monster}\
253
    -command "UIDisaster $win \"UIMakeMonster\" \"release a monster?\""
262
    -command "UIDisaster $win \"UIMakeMonster\" \"release a monster?\""
Lines 260-265 bind $win.col1.w1.f1.disasters.m <Mod2-Key> {tk_traverseToMenu %W %A} Link Here
260
  $win.col1.w1.f1.disasters.m add command\
269
  $win.col1.w1.f1.disasters.m add command\
261
    -label {Meltdown}\
270
    -label {Meltdown}\
262
    -command "UIDisaster $win \"sim MakeMeltdown\" \"have a nuclear meltdown?\""
271
    -command "UIDisaster $win \"sim MakeMeltdown\" \"have a nuclear meltdown?\""
272
  if {[sim HasAirCrash]} {
273
    $win.col1.w1.f1.disasters.m add command\
274
      -label {Air Crash}\
275
      -command "UIDisaster $win \"sim MakeAirCrash\" \"crash an airplane?\""
276
  }
263
  $win.col1.w1.f1.disasters.m add command\
277
  $win.col1.w1.f1.disasters.m add command\
264
    -label {Tornado}\
278
    -label {Tornado}\
265
    -command "UIDisaster $win \"sim MakeTornado\" \"spin up a tornado?\""
279
    -command "UIDisaster $win \"sim MakeTornado\" \"spin up a tornado?\""
Lines 276-282 menubutton $win.col1.w1.f1.priority\ Link Here
276
  -variable $win.postedMenu
290
  -variable $win.postedMenu
277
tk_bindForTraversal $win.col1.w1.f1.priority
291
tk_bindForTraversal $win.col1.w1.f1.priority
278
bind $win.col1.w1.f1.priority <F10> {tk_firstMenu %W} 
292
bind $win.col1.w1.f1.priority <F10> {tk_firstMenu %W} 
279
bind $win.col1.w1.f1.priority <Mod2-Key> {tk_traverseToMenu %W %A} 
293
bind $win.col1.w1.f1.priority <Alt-Key> {tk_traverseToMenu %W %A} 
280
294
281
tk_menus $win $win.col1.w1.f1.priority
295
tk_menus $win $win.col1.w1.f1.priority
282
296
Lines 284-290 menu $win.col1.w1.f1.priority.m\ Link Here
284
  -font [Font $win Medium]
298
  -font [Font $win Medium]
285
tk_bindForTraversal $win.col1.w1.f1.priority.m
299
tk_bindForTraversal $win.col1.w1.f1.priority.m
286
bind $win.col1.w1.f1.priority.m <F10> {tk_firstMenu %W} 
300
bind $win.col1.w1.f1.priority.m <F10> {tk_firstMenu %W} 
287
bind $win.col1.w1.f1.priority.m <Mod2-Key> {tk_traverseToMenu %W %A} 
301
bind $win.col1.w1.f1.priority.m <Alt-Key> {tk_traverseToMenu %W %A} 
288
  $win.col1.w1.f1.priority.m add radiobutton\
302
  $win.col1.w1.f1.priority.m add radiobutton\
289
    -label {Super Fast}\
303
    -label {Super Fast}\
290
    -command {SetPriority 4}\
304
    -command {SetPriority 4}\
Lines 310-315 bind $win.col1.w1.f1.priority.m <Mod2-Key> {tk_traverseToMenu %W %A} Link Here
310
    -command {SetPriority 0}\
324
    -command {SetPriority 0}\
311
    -value {0}\
325
    -value {0}\
312
    -variable Priority
326
    -variable Priority
327
  $win.col1.w1.f1.priority.m add checkbutton\
328
    -label {Pause}\
329
    -command {TogglePause}\
330
    -variable Pause
313
331
314
SetHelp $win.col1.w1.f1.windows Head.WindowsMenu
332
SetHelp $win.col1.w1.f1.windows Head.WindowsMenu
315
333
Lines 320-326 menubutton $win.col1.w1.f1.windows\ Link Here
320
  -variable $win.postedMenu
338
  -variable $win.postedMenu
321
tk_bindForTraversal $win.col1.w1.f1.windows
339
tk_bindForTraversal $win.col1.w1.f1.windows
322
bind $win.col1.w1.f1.windows <F10> {tk_firstMenu %W} 
340
bind $win.col1.w1.f1.windows <F10> {tk_firstMenu %W} 
323
bind $win.col1.w1.f1.windows <Mod2-Key> {tk_traverseToMenu %W %A} 
341
bind $win.col1.w1.f1.windows <Alt-Key> {tk_traverseToMenu %W %A} 
324
342
325
tk_menus $win $win.col1.w1.f1.windows
343
tk_menus $win $win.col1.w1.f1.windows
326
344
Lines 328-334 menu $win.col1.w1.f1.windows.m\ Link Here
328
  -font [Font $win Medium]
346
  -font [Font $win Medium]
329
tk_bindForTraversal $win.col1.w1.f1.windows.m
347
tk_bindForTraversal $win.col1.w1.f1.windows.m
330
bind $win.col1.w1.f1.windows.m <F10> {tk_firstMenu %W} 
348
bind $win.col1.w1.f1.windows.m <F10> {tk_firstMenu %W} 
331
bind $win.col1.w1.f1.windows.m <Mod2-Key> {tk_traverseToMenu %W %A} 
349
bind $win.col1.w1.f1.windows.m <Alt-Key> {tk_traverseToMenu %W %A} 
332
  $win.col1.w1.f1.windows.m add command\
350
  $win.col1.w1.f1.windows.m add command\
333
    -label {Budget}\
351
    -label {Budget}\
334
    -command "UIShowBudgetAndWait"
352
    -command "UIShowBudgetAndWait"
Lines 516-522 frame $win.col1.w1.f2.f2\ Link Here
516
  -relief flat
534
  -relief flat
517
tk_bindForTraversal $win.col1.w1.f2.f2
535
tk_bindForTraversal $win.col1.w1.f2.f2
518
bind $win.col1.w1.f2.f2 <F10> {tk_firstMenu %W} 
536
bind $win.col1.w1.f2.f2 <F10> {tk_firstMenu %W} 
519
bind $win.col1.w1.f2.f2 <Mod2-Key> {tk_traverseToMenu %W %A} 
537
bind $win.col1.w1.f2.f2 <Alt-Key> {tk_traverseToMenu %W %A} 
520
538
521
SetHelp $win.col1.w1.f2.f2 Head.Log
539
SetHelp $win.col1.w1.f2.f2 Head.Log
522
540
Lines 558-564 if {[sim MultiPlayerMode]} { Link Here
558
    -relief flat
576
    -relief flat
559
  tk_bindForTraversal $win.col1.w1.f2.f3
577
  tk_bindForTraversal $win.col1.w1.f2.f3
560
  bind $win.col1.w1.f2.f3 <F10> {tk_firstMenu %W} 
578
  bind $win.col1.w1.f2.f3 <F10> {tk_firstMenu %W} 
561
  bind $win.col1.w1.f2.f3 <Mod2-Key> {tk_traverseToMenu %W %A} 
579
  bind $win.col1.w1.f2.f3 <Alt-Key> {tk_traverseToMenu %W %A} 
562
580
563
  button $win.col1.w1.f2.f3.chat \
581
  button $win.col1.w1.f2.f3.chat \
564
    -font [Font $win Large] \
582
    -font [Font $win Large] \
Lines 581-587 if {[sim MultiPlayerMode]} { Link Here
581
  set $win.col1.w1.f2.f3.entry.value ""
599
  set $win.col1.w1.f2.f3.entry.value ""
582
  tk_bindForTraversal $win.col1.w1.f2.f3.entry
600
  tk_bindForTraversal $win.col1.w1.f2.f3.entry
583
  bind $win.col1.w1.f2.f3.entry <F10> {tk_firstMenu %W} 
601
  bind $win.col1.w1.f2.f3.entry <F10> {tk_firstMenu %W} 
584
  bind $win.col1.w1.f2.f3.entry <Mod2-Key> {tk_traverseToMenu %W %A}
602
  bind $win.col1.w1.f2.f3.entry <Alt-Key> {tk_traverseToMenu %W %A}
585
  bind $win.col1.w1.f2.f3.entry <Return> "DoEnterMessage %W %W.value"
603
  bind $win.col1.w1.f2.f3.entry <Return> "DoEnterMessage %W %W.value"
586
  bind $win.col1.w1.f2.f3.entry <Escape> "DoEvalMessage %W %W.value"
604
  bind $win.col1.w1.f2.f3.entry <Escape> "DoEvalMessage %W %W.value"
587
  bind $win.col1.w1.f2.f3.entry <Any-Enter> {focus %W}
605
  bind $win.col1.w1.f2.f3.entry <Any-Enter> {focus %W}
Lines 656-662 place configure $win.col1\ Link Here
656
  -x 0\
674
  -x 0\
657
  -y 0\
675
  -y 0\
658
  -width $HeadPanelWidth\
676
  -width $HeadPanelWidth\
659
  -height $screenheight
677
  -relheight 1.0
660
678
661
pack append $win.col1\
679
pack append $win.col1\
662
    $win.col1.w1		{top frame nw fillx} \
680
    $win.col1.w1		{top frame nw fillx} \
Lines 684-691 pack append $win.col1\ Link Here
684
place configure $win.col2\
702
place configure $win.col2\
685
  -x [expr "$HeadPanelWidth + 5"]\
703
  -x [expr "$HeadPanelWidth + 5"]\
686
  -y 0\
704
  -y 0\
687
  -width [expr "($screenwidth - $HeadPanelWidth) - 5"]\
705
  -relheight 1.0\
688
  -height $screenheight
706
  -width [expr "($screenwidth - $HeadPanelWidth) - 5"]
707
708
proc resizeeditor {win width} {
709
  global HeadPanelWidth
710
711
  place configure $win.col2\
712
    -width [expr "($width - $HeadPanelWidth) - 5"]
713
}
714
715
bind $win <Configure> "resizeeditor $win %w"
689
716
690
#pack append $win.col2\
717
#pack append $win.col2\
691
#    $win.col2.x1		{top frame nw fillx} \
718
#    $win.col2.x1		{top frame nw fillx} \
(-)a/res/wmap.tcl (-4 / +4 lines)
Lines 124-130 menubutton $win.topframe.zones\ Link Here
124
LinkWindow $win.zones $win.topframe.zones
124
LinkWindow $win.zones $win.topframe.zones
125
tk_bindForTraversal $win.topframe.zones
125
tk_bindForTraversal $win.topframe.zones
126
bind $win.topframe.zones <F10> {tk_firstMenu %W} 
126
bind $win.topframe.zones <F10> {tk_firstMenu %W} 
127
bind $win.topframe.zones <Mod2-Key> {tk_traverseToMenu %W %A} 
127
bind $win.topframe.zones <Alt-Key> {tk_traverseToMenu %W %A} 
128
tk_menus $win $win.topframe.zones
128
tk_menus $win $win.topframe.zones
129
129
130
SetHelp $win.topframe.zones Map.Zones
130
SetHelp $win.topframe.zones Map.Zones
Lines 133-139 menu $win.topframe.zones.m\ Link Here
133
  -font [Font $win Medium]
133
  -font [Font $win Medium]
134
tk_bindForTraversal $win.topframe.zones.m
134
tk_bindForTraversal $win.topframe.zones.m
135
bind $win.topframe.zones.m <F10> {tk_firstMenu %W} 
135
bind $win.topframe.zones.m <F10> {tk_firstMenu %W} 
136
bind $win.topframe.zones.m <Mod2-Key> {tk_traverseToMenu %W %A} 
136
bind $win.topframe.zones.m <Alt-Key> {tk_traverseToMenu %W %A} 
137
  $win.topframe.zones.m add radiobutton\
137
  $win.topframe.zones.m add radiobutton\
138
    -label {All}\
138
    -label {All}\
139
    -variable MapState.$win\
139
    -variable MapState.$win\
Lines 176-182 menubutton $win.topframe.overlays\ Link Here
176
LinkWindow $win.overlays $win.topframe.overlays
176
LinkWindow $win.overlays $win.topframe.overlays
177
tk_bindForTraversal $win.topframe.overlays
177
tk_bindForTraversal $win.topframe.overlays
178
bind $win.topframe.overlays <F10> {tk_firstMenu %W} 
178
bind $win.topframe.overlays <F10> {tk_firstMenu %W} 
179
bind $win.topframe.overlays <Mod2-Key> {tk_traverseToMenu %W %A} 
179
bind $win.topframe.overlays <Alt-Key> {tk_traverseToMenu %W %A} 
180
tk_menus $win $win.topframe.overlays
180
tk_menus $win $win.topframe.overlays
181
181
182
SetHelp $win.topframe.overlays Map.Overlays
182
SetHelp $win.topframe.overlays Map.Overlays
Lines 185-191 menu $win.topframe.overlays.m\ Link Here
185
  -font [Font $win Medium]
185
  -font [Font $win Medium]
186
tk_bindForTraversal $win.topframe.overlays.m
186
tk_bindForTraversal $win.topframe.overlays.m
187
bind $win.topframe.overlays.m <F10> {tk_firstMenu %W} 
187
bind $win.topframe.overlays.m <F10> {tk_firstMenu %W} 
188
bind $win.topframe.overlays.m <Mod2-Key> {tk_traverseToMenu %W %A} 
188
bind $win.topframe.overlays.m <Alt-Key> {tk_traverseToMenu %W %A} 
189
  $win.topframe.overlays.m add radiobutton\
189
  $win.topframe.overlays.m add radiobutton\
190
    -label {Population Density}\
190
    -label {Population Density}\
191
    -variable MapState.$win\
191
    -variable MapState.$win\
(-)a/res/wscen.tcl (-1 / +1 lines)
Lines 89-95 SetHelp $win Scenario Link Here
89
canvas $win.canvas \
89
canvas $win.canvas \
90
  -scrollincrement 0 \
90
  -scrollincrement 0 \
91
  -borderwidth 0 \
91
  -borderwidth 0 \
92
  -background #000000 \
92
  -background #BFBFBF \
93
  -width 1200 -height 900
93
  -width 1200 -height 900
94
LinkWindow $win.canvas $win.canvas
94
LinkWindow $win.canvas $win.canvas
95
LinkWindow $win.canvas.w $win
95
LinkWindow $win.canvas.w $win
(-)a/src/sim/g_bigmap.c (+12 lines)
Lines 169-174 MemDrawBeegMapRect(SimView *view, int x, int y, int w, int h) Link Here
169
#define ROW8_16(n) ROW4_16(n) ROW4_16(n+4)
169
#define ROW8_16(n) ROW4_16(n) ROW4_16(n+4)
170
#define ROW16_16() ROW8_16(0) ROW8_16(8)
170
#define ROW16_16() ROW8_16(0) ROW8_16(8)
171
171
172
#define ROW1_32(n) \
173
      memcpy((char *)image, (char *)mem + (4 * 16 * (n)), 4 * 16); \
174
      image = (unsigned QUAD *)(((unsigned char *)image) + lineBytes);
175
176
#define ROW2_32(n) ROW1_32(n) ROW1_32(n+1)
177
#define ROW4_32(n) ROW2_32(n) ROW2_32(n+2)
178
#define ROW8_32(n) ROW4_32(n) ROW4_32(n+4)
179
#define ROW16_32() ROW8_32(0) ROW8_32(8)
180
172
	  switch (view->x->depth) {
181
	  switch (view->x->depth) {
173
182
174
	  case 8:
183
	  case 8:
Lines 182-187 MemDrawBeegMapRect(SimView *view, int x, int y, int w, int h) Link Here
182
191
183
	  case 24:
192
	  case 24:
184
	  case 32:
193
	  case 32:
194
	    ROW16_32();
195
	    break;
196
185
	  default:
197
	  default:
186
	    /* XXX: handle different depths */
198
	    /* XXX: handle different depths */
187
	    break;
199
	    break;
(-)a/src/sim/g_cam.c (-21 / +27 lines)
Lines 1083-1121 cam_load_rule(Cam *cam, char *filename) Link Here
1083
  FILE *fp;
1083
  FILE *fp;
1084
  QUAD magic, neighborhood, rule_size;
1084
  QUAD magic, neighborhood, rule_size;
1085
  Byte *rule;
1085
  Byte *rule;
1086
  int test = 1;
1086
1087
1087
  if ((fp = fopen(filename, "r")) == NULL) {
1088
  if ((fp = fopen(filename, "r")) == NULL) {
1088
    fprintf(stderr, "cam: Can't open rule file \"%s\"\n", filename);
1089
    fprintf(stderr, "cam: Can't open rule file \"%s\"\n", filename);
1089
    return;
1090
    return;
1090
  }
1091
  }
1091
1092
1092
/* XXX: Make this byte order independent!!! */
1093
1094
#if defined(MSDOS) || defined(OSF1) || defined(IS_INTEL)
1095
1093
1096
#define SWAPQUAD(x) ((x = ((x <<24) & 0xff000000) | \
1094
#define SWAPQUAD(x) ((x = ((x <<24) & 0xff000000) | \
1097
			  ((x <<8)  & 0x00ff0000) | \
1095
			  ((x <<8)  & 0x00ff0000) | \
1098
			  ((x >>8)  & 0x0000ff00) | \
1096
			  ((x >>8)  & 0x0000ff00) | \
1099
			  ((x >>24) & 0x000000ff)), 0)
1097
			  ((x >>24) & 0x000000ff)), 0)
1100
1098
1101
#else
1099
/* XXX: Make this byte order independent!!! */
1102
1100
  if ((*(unsigned char*) (&test))) {
1103
#define SWAPQUAD(x) 0
1101
    if ((fread(&magic, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1104
1102
        SWAPQUAD(magic) ||
1105
#endif
1103
        (magic != 0xcac0cac0) ||
1106
1104
        (fread(&neighborhood, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1107
  if ((fread(&magic, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1105
        SWAPQUAD(neighborhood) ||
1108
      SWAPQUAD(magic) ||
1106
        (fread(&rule_size, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1109
      (magic != 0xcac0cac0) ||
1107
        SWAPQUAD(rule_size) ||
1110
      (fread(&neighborhood, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1108
        ((rule = (Byte *)malloc(rule_size)) == NULL) ||
1111
      SWAPQUAD(neighborhood) ||
1109
        (fread(rule, 1, rule_size, fp) != rule_size)) {
1112
      (fread(&rule_size, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1110
      fprintf(stderr, "cam: Bad rule file \"%s\"\n", filename);
1113
      SWAPQUAD(rule_size) ||
1111
      fclose(fp);
1114
      ((rule = (Byte *)malloc(rule_size)) == NULL) ||
1112
      return;
1115
      (fread(rule, 1, rule_size, fp) != rule_size)) {
1113
    }
1116
    fprintf(stderr, "cam: Bad rule file \"%s\"\n", filename);
1114
  } else {
1117
    fclose(fp);
1115
    if ((fread(&magic, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1118
    return;
1116
        (magic != 0xcac0cac0) ||
1117
        (fread(&neighborhood, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1118
        (fread(&rule_size, 1, sizeof(QUAD), fp) != sizeof(QUAD)) ||
1119
        ((rule = (Byte *)malloc(rule_size)) == NULL) ||
1120
        (fread(rule, 1, rule_size, fp) != rule_size)) {
1121
      fprintf(stderr, "cam: Bad rule file \"%s\"\n", filename);
1122
      fclose(fp);
1123
      return;
1124
    }
1119
  }
1125
  }
1120
1126
1121
  fclose(fp);
1127
  fclose(fp);
(-)a/src/sim/g_map.c (-63 / +47 lines)
Lines 219-225 drawFireRadius(SimView *view) Link Here
219
  short x, y;
219
  short x, y;
220
220
221
  drawAll(view);
221
  drawAll(view);
222
  for (x = 0; x < SmY; x++) {
222
  for (x = 0; x < SmX; x++) {
223
    for (y = 0; y < SmY; y++) {
223
    for (y = 0; y < SmY; y++) {
224
      maybeDrawRect(view, GetCI(FireRate[x][y]),
224
      maybeDrawRect(view, GetCI(FireRate[x][y]),
225
		    x * 24, y * 24, 24, 24);
225
		    x * 24, y * 24, 24, 24);
Lines 406-430 drawRect(SimView *view, int pixel, int solid, Link Here
406
	unsigned char *image = 
406
	unsigned char *image = 
407
	  &data[(line * y) + (x * pixelBytes)];
407
	  &data[(line * y) + (x * pixelBytes)];
408
408
409
	if (solid) {
409
	for (i = h; i > 0; i--) {
410
	  for (i = h; i > 0; i--) {
410
	  for (j = w; j > 0; j--) {
411
	    for (j = w; j > 0; j--) {
411
	    if (solid || stipple++ & 1)
412
	      *image = pixel;
412
	      *image = pixel;
413
	      image++;
413
	    image++;
414
	    }
415
	    image += line - w;
416
	  }
417
	} else {
418
	  for (i = h; i > 0; i--) {
419
	    for (j = w; j > 0; j--) {
420
	      if (stipple++ & 1)
421
		*image = pixel;
422
	      image++;
423
	    }
424
	    if (!(w & 1))
425
	      stipple++;
426
	    image += line - w;
427
	  }
414
	  }
415
	  if (!(w & 1))
416
	    stipple++;
417
	  image += line - w;
428
	}
418
	}
429
      }
419
      }
430
      break;
420
      break;
Lines 438-463 drawRect(SimView *view, int pixel, int solid, Link Here
438
	image = 
428
	image = 
439
	  &data[(line * y) + x];
429
	  &data[(line * y) + x];
440
430
441
	if (solid) {
431
	for (i = h; i > 0; i--) {
442
	  for (i = h; i > 0; i--) {
432
	  for (j = w; j > 0; j--) {
443
	    for (j = w; j > 0; j--) {
433
	    if (solid || stipple++ & 1) {
444
	      *image = pixel;
434
	      if (view->x->x_big_endian) {
445
	      image++;
435
	        *image = ((pixel & 0xff) << 8) | ((pixel & 0xff00) >> 8);
446
	    }
436
	      } else {
447
	    image += line - w;
437
	        *image = pixel;
448
	  }
438
	      }
449
	} else {
450
	  for (i = h; i > 0; i--) {
451
	    for (j = w; j > 0; j--) {
452
	      if (stipple++ & 1)
453
		*image = pixel;
454
	      image++;
455
	    }
439
	    }
456
	    if (!(w & 1))
440
	    image++;
457
	      stipple++;
458
	    image += line - w;
459
	  }
441
	  }
442
	  if (!(w & 1))
443
	    stipple++;
444
	  image += line - w;
460
	}
445
	}
446
461
      }
447
      }
462
      break;
448
      break;
463
449
Lines 467-507 drawRect(SimView *view, int pixel, int solid, Link Here
467
	unsigned char *data = 
453
	unsigned char *data = 
468
	  (unsigned char *)view->data;
454
	  (unsigned char *)view->data;
469
	unsigned char *image;
455
	unsigned char *image;
470
	int bitmapPad = view->x->small_tile_image->bitmap_pad;
471
	int rowBytes = view->x->small_tile_image->bytes_per_line;
472
	line = rowBytes >> 1; /* Convert from byte offset to short offset */
473
	image = 
456
	image = 
474
	  &data[(line * y) + x];
457
	  &data[(line * y) + x * pixelBytes];
475
458
476
	if (solid) {
459
	for (i = h; i > 0; i--) {
477
	  for (i = h; i > 0; i--) {
460
	  for (j = w; j > 0; j--) {
478
	    for (j = w; j > 0; j--) {
461
	    if (view->x->x_big_endian) {
479
	      *(image++) = (pixel >> 0) & 0xff;
462
	      if (pixelBytes == 4) {
480
	      *(image++) = (pixel >> 8) & 0xff;
481
	      *(image++) = (pixel >> 16) & 0xff;
482
	      if (bitmapPad == 32) {
483
	        image++;
463
	        image++;
484
	      }
464
	      }
485
	    }
465
	      if (solid || stipple++ & 1) {
486
	    image += line - w;
466
	        *(image++) = (pixel >> 16) & 0xff;
487
	  }
467
	        *(image++) = (pixel >> 8) & 0xff;
488
	} else {
468
	        *(image++) = (pixel >> 0) & 0xff;
489
	  for (i = h; i > 0; i--) {
469
	      } else {
490
	    for (j = w; j > 0; j--) {
470
	        image += 3;
491
	      if (stipple++ & 1) {
471
	      }
492
		*(image++) = (pixel >> 0) & 0xff;
472
	    } else {
493
		*(image++) = (pixel >> 8) & 0xff;
473
	      if (solid || stipple++ & 1) {
494
		*(image++) = (pixel >> 16) & 0xff;
474
	        *(image++) = (pixel >> 0) & 0xff;
495
	        if (bitmapPad == 32) {
475
	        *(image++) = (pixel >> 8) & 0xff;
496
		  image++;
476
	        *(image++) = (pixel >> 16) & 0xff;
497
		}
477
	      } else {
478
	        image += 3;
479
	      }
480
	      if (pixelBytes == 4) {
481
	        image++;
498
	      }
482
	      }
499
	    }
483
	    }
500
	    if (!(w & 1)) {
501
	      stipple++;
502
	    }
503
	    image += line - w;
504
	  }
484
	  }
485
	  if (!(w & 1)) {
486
	    stipple++;
487
	  }
488
	  image += line - w * pixelBytes;
505
	}
489
	}
506
      }
490
      }
507
      break;
491
      break;
(-)a/src/sim/g_smmaps.c (-31 / +54 lines)
Lines 84-146 int DynamicData[32]; Link Here
84
      if (tile >= TILE_COUNT) tile -= TILE_COUNT;
84
      if (tile >= TILE_COUNT) tile -= TILE_COUNT;
85
85
86
86
87
#if defined(MSDOS) || defined(OSF1) || defined(IS_INTEL)
87
#define LE_ROW1_8(n) \
88
89
#define ROW1_8(n) \
90
      l = mem[n]; \
88
      l = mem[n]; \
91
      image[0] = l; \
89
      image[0] = l; \
92
      image[1] = l >>8; \
90
      image[1] = l >>8; \
93
      image[2] = l >>16; \
91
      image[2] = l >>16; \
94
      image += lineBytes;
92
      image += lineBytes;
95
93
96
#define ROW1_16(n) \
94
#define LE_ROW1_16(n) \
97
      memcpy((char *)image, ((char *)mem) + (n * 4 * 2), (3 * 2)); \
95
      memcpy((char *)image, ((char *)mem) + (n * 4 * 2), (3 * 2)); \
98
      image += lineBytes;
96
      image += lineBytes;
99
97
100
#define ROW1_24(n) \
98
#define LE_ROW1_24(n) \
101
      memcpy((char *)image, ((char *)mem) + (n * 4 * 3), (3 * 3)); \
99
      memcpy((char *)image, ((char *)mem) + (n * 4 * 3), (3 * 3)); \
102
      image += lineBytes;
100
      image += lineBytes;
103
101
104
#define ROW1_32(n) \
102
#define LE_ROW1_32(n) \
105
      memcpy((char *)image, ((char *)mem) + (n * 4 * 4), (3 * 4)); \
103
      memcpy((char *)image, ((char *)mem) + (n * 4 * 4), (3 * 4)); \
106
      image += lineBytes;
104
      image += lineBytes;
107
105
108
#else
106
#define BE_ROW1_8(n) \
109
110
#define ROW1_8(n) \
111
      l = mem[n]; \
107
      l = mem[n]; \
112
      image[0] = l >>24; \
108
      image[0] = l >>24; \
113
      image[1] = l >>16; \
109
      image[1] = l >>16; \
114
      image[2] = l >>8; \
110
      image[2] = l >>8; \
115
      image += lineBytes;
111
      image += lineBytes;
116
112
117
#define ROW1_16(n) \
113
#define BE_ROW1_16(n) \
118
      l = mem[n]; /* XXX: WRONG. handle depth */ \
114
      l = mem[n]; /* XXX: WRONG. handle depth */ \
119
      image[0] = l >>24; \
115
      image[0] = l >>24; \
120
      image[1] = l >>16; \
116
      image[1] = l >>16; \
121
      image[2] = l >>8; \
117
      image[2] = l >>8; \
122
      image += lineBytes;
118
      image += lineBytes;
123
119
124
#define ROW1_24(n) \
120
#define BE_ROW1_24(n) \
125
      l = mem[n]; /* XXX: WRONG. handle depth */ \
121
      l = mem[n]; /* XXX: WRONG. handle depth */ \
126
      image[0] = l >>24; \
122
      image[0] = l >>24; \
127
      image[1] = l >>16; \
123
      image[1] = l >>16; \
128
      image[2] = l >>8; \
124
      image[2] = l >>8; \
129
      image += lineBytes;
125
      image += lineBytes;
130
126
131
#define ROW1_32(n) \
127
#define BE_ROW1_32(n) \
132
      l = mem[n]; /* XXX: WRONG. handle depth */ \
128
      l = mem[n]; /* XXX: WRONG. handle depth */ \
133
      image[0] = l >>24; \
129
      image[0] = l >>24; \
134
      image[1] = l >>16; \
130
      image[1] = l >>16; \
135
      image[2] = l >>8; \
131
      image[2] = l >>8; \
136
      image += lineBytes;
132
      image += lineBytes;
137
133
138
#endif
134
#define LE_ROW3_8 LE_ROW1_8(0) LE_ROW1_8(1) LE_ROW1_8(2)
135
#define LE_ROW3_16 LE_ROW1_16(0) LE_ROW1_16(1) LE_ROW1_16(2)
136
#define LE_ROW3_24 LE_ROW1_24(0) LE_ROW1_24(1) LE_ROW1_24(2)
137
#define LE_ROW3_32 LE_ROW1_32(0) LE_ROW1_32(1) LE_ROW1_32(2)
139
138
140
#define ROW3_8 ROW1_8(0) ROW1_8(1) ROW1_8(2)
139
#define BE_ROW3_8 BE_ROW1_8(0) BE_ROW1_8(1) BE_ROW1_8(2)
141
#define ROW3_16 ROW1_16(0) ROW1_16(1) ROW1_16(2)
140
#define BE_ROW3_16 BE_ROW1_16(0) BE_ROW1_16(1) BE_ROW1_16(2)
142
#define ROW3_24 ROW1_24(0) ROW1_24(1) ROW1_24(2)
141
#define BE_ROW3_24 BE_ROW1_24(0) BE_ROW1_24(1) BE_ROW1_24(2)
143
#define ROW3_32 ROW1_32(0) ROW1_32(1) ROW1_32(2)
142
#define BE_ROW3_32 BE_ROW1_32(0) BE_ROW1_32(1) BE_ROW1_32(2)
143
144
#define ROW3_8 if (view->x->needs_swap) { BE_ROW3_8 } else { LE_ROW3_8 }
145
#define ROW3_16 LE_ROW3_16
146
#define ROW3_24 LE_ROW3_24
147
#define ROW3_32 LE_ROW3_32
144
148
145
#define ROW3 \
149
#define ROW3 \
146
	  switch (view->x->depth) { \
150
	  switch (view->x->depth) { \
Lines 153-160 int DynamicData[32]; Link Here
153
		  ROW3_16 \
157
		  ROW3_16 \
154
		  break; \
158
		  break; \
155
		case 24: \
159
		case 24: \
156
		  ROW3_24 \
157
		  break; \
158
		case 32: \
160
		case 32: \
159
		  ROW3_32 \
161
		  ROW3_32 \
160
		  break; \
162
		  break; \
Lines 293-306 void drawPower(SimView *view) Link Here
293
		case 16:
295
		case 16:
294
		  { 
296
		  { 
295
			unsigned short *p;
297
			unsigned short *p;
296
			p = (short *)image;
298
			p = (unsigned short *)image;
297
			p[0] = p[1] = p[2] = pix;
299
			if (view->x->x_big_endian) {
300
			  p[0] = p[1] = p[2] = ((pix & 0xff) << 8) | ((pix & 0xff00) >> 8);
301
			} else {
302
			  p[0] = p[1] = p[2] = pix;
303
			}
298
			image += lineBytes;
304
			image += lineBytes;
299
			p = (short *)image;
305
			p = (unsigned short *)image;
300
			p[0] = p[1] = p[2] = pix;
306
			if (view->x->x_big_endian) {
307
			  p[0] = p[1] = p[2] = ((pix & 0xff) << 8) | ((pix & 0xff00) >> 8);
308
			} else {
309
			  p[0] = p[1] = p[2] = pix;
310
			}
301
			image += lineBytes;
311
			image += lineBytes;
302
			p = (short *)image;
312
			p = (unsigned short *)image;
303
			p[0] = p[1] = p[2] = pix;
313
			if (view->x->x_big_endian) {
314
			  p[0] = p[1] = p[2] = ((pix & 0xff) << 8) | ((pix & 0xff00) >> 8);
315
			} else {
316
			  p[0] = p[1] = p[2] = pix;
317
			}
304
			image += lineBytes;
318
			image += lineBytes;
305
		  }
319
		  }
306
		  break;
320
		  break;
Lines 313-324 void drawPower(SimView *view) Link Here
313
			  unsigned char *img =
327
			  unsigned char *img =
314
				image;
328
				image;
315
			  for (x = 0; x < 4; x++) {
329
			  for (x = 0; x < 4; x++) {
316
				*(img++) = (pix >> 0) & 0xff;
330
			  	if (view->x->x_big_endian) {
317
				*(img++) = (pix >> 8) & 0xff;
331
				  if (pixelBytes == 4) {
318
				*(img++) = (pix >> 16) & 0xff;
332
				    img++;
319
				if (pixelBytes == 4) {
333
				  } // if
320
				  img++;
334
				  *(img++) = (pix >> 16) & 0xff;
321
				} // if
335
				  *(img++) = (pix >> 8) & 0xff;
336
				  *(img++) = (pix >> 0) & 0xff;
337
				} else {
338
				  *(img++) = (pix >> 0) & 0xff;
339
				  *(img++) = (pix >> 8) & 0xff;
340
				  *(img++) = (pix >> 16) & 0xff;
341
				  if (pixelBytes == 4) {
342
				    img++;
343
				  } // if
344
				}
322
			  } // for x
345
			  } // for x
323
			  image += lineBytes;
346
			  image += lineBytes;
324
			} // for y
347
			} // for y
(-)a/src/sim/headers/sim.h (-5 / +1 lines)
Lines 91-97 Link Here
91
#include <assert.h>
91
#include <assert.h>
92
#include <ctype.h>
92
#include <ctype.h>
93
#include <setjmp.h>
93
#include <setjmp.h>
94
#include <malloc.h>
95
#include <errno.h>
94
#include <errno.h>
96
#include <signal.h>
95
#include <signal.h>
97
#include <math.h>
96
#include <math.h>
Lines 103-118 Link Here
103
#include <sys/ioctl.h>
102
#include <sys/ioctl.h>
104
#include <sys/resource.h>
103
#include <sys/resource.h>
105
#ifndef MSDOS
104
#ifndef MSDOS
106
#ifndef HPUX
107
#include <alloca.h>
108
#endif
109
#include <sys/mman.h>
105
#include <sys/mman.h>
110
#include <netinet/in.h>
106
#include <netinet/in.h>
111
#include <arpa/inet.h>
107
#include <arpa/inet.h>
112
#endif
108
#endif
113
109
114
#ifdef sun
110
#ifdef sun
115
#ifdef SOLARIS2
111
#ifdef __SVR4
116
#include <sys/systeminfo.h>
112
#include <sys/systeminfo.h>
117
#else
113
#else
118
#include <sys/vadvise.h>
114
#include <sys/vadvise.h>
(-)a/src/sim/headers/view.h (+2 lines)
Lines 113-118 typedef struct XDisplay { Link Here
113
  Pixmap vert_stipple;
113
  Pixmap vert_stipple;
114
  Pixmap horiz_stipple;
114
  Pixmap horiz_stipple;
115
  Pixmap diag_stipple;
115
  Pixmap diag_stipple;
116
  int needs_swap;
117
  int x_big_endian;
116
} XDisplay;
118
} XDisplay;
117
119
118
120
(-)a/src/sim/makefile (-3 / +4 lines)
Lines 10-21 CC = gcc Link Here
10
OPTFLAGS = -O3
10
OPTFLAGS = -O3
11
#OPTFLAGS = -g
11
#OPTFLAGS = -g
12
12
13
#DEFINES = -DIS_LINUX -DIS_INTEL -DCAM -DNET
13
#DEFINES = -DIS_LINUX -DCAM -DNET
14
DEFINES = -DIS_LINUX -DIS_INTEL
14
DEFINES = -DIS_LINUX -DNO_AIRCRASH
15
15
16
CFLAGS = $(OPTFLAGS) $(DEFINES)
16
CFLAGS = $(OPTFLAGS) $(DEFINES)
17
17
18
#LDFLAGS = -Bstatic
18
#LDFLAGS = -Bstatic
19
LDFLAGS=-L/usr/X11/lib -L/usr/X11R6/lib
19
20
20
INSTALL = install -s
21
INSTALL = install -s
21
22
Lines 96-102 all: sim Link Here
96
lint:
97
lint:
97
	alint $(INCLUDES) $(SRCS) > LINT
98
	alint $(INCLUDES) $(SRCS) > LINT
98
99
99
sim: $(ALLOBJS)
100
sim: $(ALLOBJS) $(TCLXHOME)/libtk.a $(TCLXHOME)/libtcl.a
100
	$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) $(ALLOBJS) $(LIBS) -o sim
101
	$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) $(ALLOBJS) $(LIBS) -o sim
101
102
102
clean:
103
clean:
(-)a/src/sim/s_disast.c (+1 lines)
Lines 97-102 DoDisasters(void) Link Here
97
      MakeFlood();
97
      MakeFlood();
98
      break;
98
      break;
99
    case 4:
99
    case 4:
100
      MakeAirCrash();
100
      break;
101
      break;
101
    case 5:
102
    case 5:
102
      MakeTornado();
103
      MakeTornado();
(-)a/src/sim/s_fileio.c (-11 / +8 lines)
Lines 62-78 Link Here
62
#include "sim.h"
62
#include "sim.h"
63
63
64
64
65
#if defined(MSDOS) || defined(OSF1) || defined(IS_INTEL)
66
67
#define SWAP_SHORTS(a,b)	_swap_shorts(a,b)
65
#define SWAP_SHORTS(a,b)	_swap_shorts(a,b)
68
#define SWAP_LONGS(a,b)		_swap_longs(a,b)
66
#define SWAP_LONGS(a,b)		_swap_longs(a,b)
69
#define HALF_SWAP_LONGS(a,b)	_half_swap_longs(a,b)
67
#define HALF_SWAP_LONGS(a,b)	_half_swap_longs(a,b)
70
68
69
#define NOOP_ON_BE	{ int test = 1; if (!(*(unsigned char*) (&test))) return; }
70
71
static void
71
static void
72
_swap_shorts(short *buf, int len)
72
_swap_shorts(short *buf, int len)
73
{
73
{
74
  int i;
74
  int i;
75
75
76
  NOOP_ON_BE;
77
76
  /* Flip bytes in each short! */
78
  /* Flip bytes in each short! */
77
  for (i = 0; i < len; i++) {	
79
  for (i = 0; i < len; i++) {	
78
    *buf = ((*buf & 0xFF) <<8) | ((*buf &0xFF00) >>8);
80
    *buf = ((*buf & 0xFF) <<8) | ((*buf &0xFF00) >>8);
Lines 85-90 _swap_longs(long *buf, int len) Link Here
85
{
87
{
86
  int i;
88
  int i;
87
89
90
  NOOP_ON_BE;
91
88
  /* Flip bytes in each long! */
92
  /* Flip bytes in each long! */
89
  for (i = 0; i < len; i++) {	
93
  for (i = 0; i < len; i++) {	
90
    long l = *buf;
94
    long l = *buf;
Lines 102-107 _half_swap_longs(long *buf, int len) Link Here
102
{
106
{
103
  int i;
107
  int i;
104
108
109
  NOOP_ON_BE
110
105
  /* Flip bytes in each long! */
111
  /* Flip bytes in each long! */
106
  for (i = 0; i < len; i++) {	
112
  for (i = 0; i < len; i++) {	
107
    long l = *buf;
113
    long l = *buf;
Lines 112-126 _half_swap_longs(long *buf, int len) Link Here
112
  }
118
  }
113
}
119
}
114
120
115
#else
116
117
#define SWAP_SHORTS(a, b)
118
#define SWAP_LONGS(a, b)
119
#define HALF_SWAP_LONGS(a, b)
120
121
#endif
122
123
124
static int
121
static int
125
_load_short(short *buf, int len, FILE *f)
122
_load_short(short *buf, int len, FILE *f)
126
{
123
{
(-)a/src/sim/w_resrc.c (-1 / +1 lines)
Lines 71-77 Link Here
71
#endif
71
#endif
72
72
73
73
74
char *HomeDir, *ResourceDir, *KeyDir, *HostName;
74
char *HomeDir, *ResourceDir, *KeyDir, *HostName = "";
75
75
76
struct Resource *Resources = NULL;
76
struct Resource *Resources = NULL;
77
77
(-)a/src/sim/w_sim.c (+19 lines)
Lines 145-150 SIMCMD_CALL(StartBulldozer) Link Here
145
SIMCMD_CALL(StopBulldozer)
145
SIMCMD_CALL(StopBulldozer)
146
SIMCMD_CALL(MakeFire)
146
SIMCMD_CALL(MakeFire)
147
SIMCMD_CALL(MakeFlood)
147
SIMCMD_CALL(MakeFlood)
148
SIMCMD_CALL(MakeAirCrash)
148
SIMCMD_CALL(MakeTornado)
149
SIMCMD_CALL(MakeTornado)
149
SIMCMD_CALL(MakeEarthquake)
150
SIMCMD_CALL(MakeEarthquake)
150
SIMCMD_CALL(MakeMonster)
151
SIMCMD_CALL(MakeMonster)
Lines 1511-1516 int SimCmdSugarMode(ARGS) Link Here
1511
  return (TCL_OK);
1512
  return (TCL_OK);
1512
}
1513
}
1513
1514
1515
int SimCmdHasAirCrash(ARGS)
1516
{
1517
  int aircrash = 0;
1518
1519
  if (argc != 2) {
1520
    return (TCL_ERROR);
1521
  }
1522
1523
#ifndef NO_AIRCRASH
1524
  aircrash = 1;
1525
#endif
1526
1527
  sprintf(interp->result, "%d", aircrash);
1528
  return (TCL_OK);
1529
}
1530
1514
1531
1515
/************************************************************************/
1532
/************************************************************************/
1516
1533
Lines 1567-1572 sim_command_init() Link Here
1567
  SIM_CMD(StopBulldozer);
1584
  SIM_CMD(StopBulldozer);
1568
  SIM_CMD(MakeFire);
1585
  SIM_CMD(MakeFire);
1569
  SIM_CMD(MakeFlood);
1586
  SIM_CMD(MakeFlood);
1587
  SIM_CMD(MakeAirCrash);
1570
  SIM_CMD(MakeTornado);
1588
  SIM_CMD(MakeTornado);
1571
  SIM_CMD(MakeEarthquake);
1589
  SIM_CMD(MakeEarthquake);
1572
  SIM_CMD(MakeMonster);
1590
  SIM_CMD(MakeMonster);
Lines 1674-1677 sim_command_init() Link Here
1674
  SIM_CMD(NeedRest);
1692
  SIM_CMD(NeedRest);
1675
  SIM_CMD(MultiPlayerMode);
1693
  SIM_CMD(MultiPlayerMode);
1676
  SIM_CMD(SugarMode);
1694
  SIM_CMD(SugarMode);
1695
  SIM_CMD(HasAirCrash);
1677
}
1696
}
(-)a/src/sim/w_sprite.c (-5 / +24 lines)
Lines 898-908 DoShipSprite(SimSprite *sprite) Link Here
898
    sprite->frame = 0;
898
    sprite->frame = 0;
899
    return;
899
    return;
900
  }
900
  }
901
  for (z = 0; z < 8; z++) {
901
  if (!NoDisasters) {
902
    if (t == BtClrTab[z]) break;
902
    for (z = 0; z < 8; z++) {
903
    if (z == 7) {
903
      if (t == BtClrTab[z]) break;
904
      ExplodeSprite(sprite);
904
      if (z == 7) {
905
      Destroy(sprite->x + 48, sprite->y);
905
        ExplodeSprite(sprite);
906
        Destroy(sprite->x + 48, sprite->y);
907
      }
906
    }
908
    }
907
  }
909
  }
908
}
910
}
Lines 1588-1593 GeneratePlane(int x, int y) Link Here
1588
}
1590
}
1589
1591
1590
1592
1593
MakeAirCrash(void)
1594
{
1595
#ifndef NO_AIRCRASH
1596
  if (GetSprite(AIR) == NULL) {
1597
    short x, y;
1598
1599
    x = Rand(WORLD_X - 20) + 10;
1600
    y = Rand(WORLD_Y - 10) + 5;
1601
1602
    GeneratePlane(x, y);
1603
  }
1604
1605
  ExplodeSprite(GetSprite(AIR));
1606
#endif
1607
}
1608
1609
1591
MakeTornado(void)
1610
MakeTornado(void)
1592
{
1611
{
1593
  short x, y;
1612
  short x, y;
(-)a/src/sim/w_tk.c (-3 / +3 lines)
Lines 475-482 TileViewEventProc(ClientData clientData, XEvent *eventPtr) Link Here
475
/* XXX: redraw all views showing cursor */
475
/* XXX: redraw all views showing cursor */
476
/* XXX: also, make sure switching tools works w/out moving */
476
/* XXX: also, make sure switching tools works w/out moving */
477
    if (((view->tool_showing != last_showing) ||
477
    if (((view->tool_showing != last_showing) ||
478
	 (view->tool_x != last_x) ||
478
        ((view->tool_x >> 4) != (last_x >> 4)) ||
479
	 (view->tool_y != last_y))) {
479
        ((view->tool_y >> 4)  != (last_y >> 4)))) {
480
#if 1
480
#if 1
481
      EventuallyRedrawView(view);
481
      EventuallyRedrawView(view);
482
#else
482
#else
Lines 819-825 tk_main() Link Here
819
819
820
  Tk_MainLoop();
820
  Tk_MainLoop();
821
821
822
  sim_exit(0); // Just sets tkMustExit and ExitReturn
822
  sim_really_exit(0);
823
823
824
 bail:
824
 bail:
825
825
(-)a/src/sim/w_x.c (-8 / +29 lines)
Lines 327-354 FindXDisplay(Tk_Window tkwin) Link Here
327
	      color->pixel; \
327
	      color->pixel; \
328
	    break; \
328
	    break; \
329
	  case 15: \
329
	  case 15: \
330
	    if (xd->visual->red_mask == 0x7c00) { \
330
	    xd->pixels[i] = \
331
	    xd->pixels[i] = \
331
	      (((color->red >> (8 + 3)) & 0x1f) << (5 + 5)) | \
332
	      (((color->red >> (8 + 3)) & 0x1f) << (5 + 5)) | \
332
	      (((color->green >> (8 + 2)) & 0x1f) << (5)) | \
333
	      (((color->green >> (8 + 2)) & 0x1f) << (5)) | \
333
	      (((color->blue >> (8 + 3)) & 0x1f) << (0)); \
334
	      (((color->blue >> (8 + 3)) & 0x1f) << (0)); \
335
	    } else { \
336
	      (((color->blue >> (8 + 3)) & 0x1f) << (5 + 5)) | \
337
	      (((color->green >> (8 + 2)) & 0x1f) << (5)) | \
338
	      (((color->red >> (8 + 3)) & 0x1f) << (0)); \
339
	    } \
334
	    break; \
340
	    break; \
335
	  case 16: \
341
	  case 16: \
342
	    if (xd->visual->red_mask == 0xf800) { \
336
	    xd->pixels[i] = \
343
	    xd->pixels[i] = \
337
	      (((color->red >> (8 + 3)) & 0x1f) << (6 + 5)) | \
344
	      (((color->red >> (8 + 3)) & 0x1f) << (6 + 5)) | \
338
	      (((color->green >> (8 + 2)) & 0x3f) << (5)) | \
345
	      (((color->green >> (8 + 2)) & 0x3f) << (5)) | \
339
	      (((color->blue >> (8 + 3)) & 0x1f) << (0)); \
346
	      (((color->blue >> (8 + 3)) & 0x1f) << (0)); \
347
	    } else { \
348
	    xd->pixels[i] = \
349
	      (((color->blue >> (8 + 3)) & 0x1f) << (6 + 5)) | \
350
	      (((color->green >> (8 + 2)) & 0x3f) << (5)) | \
351
	      (((color->red >> (8 + 3)) & 0x1f) << (0)); \
352
	    } \
340
	    break; \
353
	    break; \
341
	  case 24: \
354
	  case 24: \
355
	  case 32: \
356
	    if (xd->visual->red_mask == 0xff0000) { \
342
	    xd->pixels[i] = \
357
	    xd->pixels[i] = \
343
	      ((color->red & 0xff) << 16) | \
358
	      ((color->red & 0xff) << 16) | \
344
	      ((color->green & 0xff) << 8) | \
359
	      ((color->green & 0xff) << 8) | \
345
	      ((color->blue & 0xff) << 0); \
360
	      ((color->blue & 0xff) << 0); \
346
	    break; \
361
	    } else { \
347
	  case 32: \
348
	    xd->pixels[i] = \
362
	    xd->pixels[i] = \
349
	      ((color->red & 0xff) << 16) | \
363
	      ((color->blue & 0xff) << 16) | \
350
	      ((color->green & 0xff) << 8) | \
364
	      ((color->green & 0xff) << 8) | \
351
	      ((color->blue & 0xff) << 0); \
365
	      ((color->red & 0xff) << 0); \
366
	    } \
352
	    break; \
367
	    break; \
353
	  } \
368
	  } \
354
	} \
369
	} \
Lines 488-493 SimView * Link Here
488
InitNewView(SimView *view, char *title, int class, int w, int h)
503
InitNewView(SimView *view, char *title, int class, int w, int h)
489
{
504
{
490
  int type, i;
505
  int type, i;
506
  int test = 1;
491
  int d = 8;
507
  int d = 8;
492
  unsigned long valuemask = 0;
508
  unsigned long valuemask = 0;
493
  char *t;
509
  char *t;
Lines 582-587 InitNewView(SimView *view, char *title, int class, int w, int h) Link Here
582
    view->type = X_Mem_View;
598
    view->type = X_Mem_View;
583
  }
599
  }
584
600
601
  view->x->needs_swap = !(*(unsigned char*) (&test));
602
  view->x->x_big_endian = (ImageByteOrder(view->x->dpy) == MSBFirst);
603
604
585
  GetPixmaps(view->x);
605
  GetPixmaps(view->x);
586
  view->pixels = view->x->pixels;
606
  view->pixels = view->x->pixels;
587
607
Lines 591-598 InitNewView(SimView *view, char *title, int class, int w, int h) Link Here
591
  view->pan_x = w / 2; view->pan_y = h / 2;
611
  view->pan_x = w / 2; view->pan_y = h / 2;
592
  DoResizeView(view, w, h);
612
  DoResizeView(view, w, h);
593
613
594
  GetViewTiles(view);
595
596
  return (view);
614
  return (view);
597
}
615
}
598
616
Lines 1138-1144 DoResizeView(SimView *view, int w, int h) Link Here
1138
	  view->pixel_bytes = 2;
1156
	  view->pixel_bytes = 2;
1139
	  view->depth = 15;
1157
	  view->depth = 15;
1140
	  bitmap_pad = 16;
1158
	  bitmap_pad = 16;
1141
	  bitmap_depth = 16;
1159
	  bitmap_depth = 15;
1142
	  view->line_bytes8 =
1160
	  view->line_bytes8 =
1143
	    ((view->m_width * view->pixel_bytes) + 3) & (~3);
1161
	    ((view->m_width * view->pixel_bytes) + 3) & (~3);
1144
	  break;
1162
	  break;
Lines 1156-1162 DoResizeView(SimView *view, int w, int h) Link Here
1156
	  view->pixel_bytes = 4;
1174
	  view->pixel_bytes = 4;
1157
	  //view->pixel_bytes = 3;
1175
	  //view->pixel_bytes = 3;
1158
	  view->depth = 24;
1176
	  view->depth = 24;
1159
	  bitmap_depth = 32;
1177
	  bitmap_depth = 24;
1160
	  bitmap_pad = 32;
1178
	  bitmap_pad = 32;
1161
	  view->line_bytes8 =
1179
	  view->line_bytes8 =
1162
	    ((view->m_width * 4) + 3) & (~3);
1180
	    ((view->m_width * 4) + 3) & (~3);
Lines 1224-1229 DoResizeView(SimView *view, int w, int h) Link Here
1224
      }
1242
      }
1225
    }
1243
    }
1226
  }
1244
  }
1245
1246
  GetViewTiles(view);
1247
1227
}
1248
}
1228
1249
1229
1250
(-)a/src/tcl/tclenv.c (-33 / +10 lines)
Lines 1-7 Link Here
1
/* 
1
/* 
2
 * tclEnv.c --
2
 * tclEnv.c --
3
 *
3
 *
4
 *	Tcl support for environment variables, including a setenv
4
 *	Tcl support for environment variables, including a setenv_tcl
5
 *	procedure.
5
 *	procedure.
6
 *
6
 *
7
 * Copyright 1991 Regents of the University of California
7
 * Copyright 1991 Regents of the University of California
Lines 57-69 static char * EnvTraceProc _ANSI_ARGS_((ClientData clientData, Link Here
57
			    int flags));
57
			    int flags));
58
static int		FindVariable _ANSI_ARGS_((char *name, int *lengthPtr));
58
static int		FindVariable _ANSI_ARGS_((char *name, int *lengthPtr));
59
59
60
#ifdef IS_LINUX
60
void			setenv_tcl _ANSI_ARGS_((char *name, char *value));
61
int			setenv _ANSI_ARGS_((const char *name, const char *value, int replace));
61
int			unsetenv_tcl _ANSI_ARGS_((char *name));
62
int			unsetenv _ANSI_ARGS_((const char *name));
63
#else
64
void			setenv _ANSI_ARGS_((char *name, char *value));
65
void			unsetenv _ANSI_ARGS_((char *name));
66
#endif
67
62
68
63
69
/*
64
/*
Lines 188-194 FindVariable(name, lengthPtr) Link Here
188
/*
183
/*
189
 *----------------------------------------------------------------------
184
 *----------------------------------------------------------------------
190
 *
185
 *
191
 * setenv --
186
 * setenv_tcl --
192
 *
187
 *
193
 *	Set an environment variable, replacing an existing value
188
 *	Set an environment variable, replacing an existing value
194
 *	or creating a new variable if there doesn't exist a variable
189
 *	or creating a new variable if there doesn't exist a variable
Lines 204-223 FindVariable(name, lengthPtr) Link Here
204
 *----------------------------------------------------------------------
199
 *----------------------------------------------------------------------
205
 */
200
 */
206
201
207
#ifdef IS_LINUX
208
int
209
setenv(name, value, replace)
210
    const char *name;		/* Name of variable whose value is to be
211
				 * set. */
212
    const char *value;		/* New value for variable. */
213
    int replace;
214
#else
215
void
202
void
216
setenv(name, value)
203
setenv_tcl(name, value)
217
    char *name;			/* Name of variable whose value is to be
204
    char *name;			/* Name of variable whose value is to be
218
				 * set. */
205
				 * set. */
219
    char *value;		/* New value for variable. */
206
    char *value;		/* New value for variable. */
220
#endif
221
{
207
{
222
    int index, length, nameLength;
208
    int index, length, nameLength;
223
    char *p;
209
    char *p;
Lines 272-288 setenv(name, value) Link Here
272
    for (eiPtr= firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) {
258
    for (eiPtr= firstInterpPtr; eiPtr != NULL; eiPtr = eiPtr->nextPtr) {
273
	(void) Tcl_SetVar2(eiPtr->interp, "env", (char *)name, p+1, TCL_GLOBAL_ONLY);
259
	(void) Tcl_SetVar2(eiPtr->interp, "env", (char *)name, p+1, TCL_GLOBAL_ONLY);
274
    }
260
    }
275
276
#ifdef IS_LINUX
277
    return 0;
278
#endif
279
280
}
261
}
281
262
282
/*
263
/*
283
 *----------------------------------------------------------------------
264
 *----------------------------------------------------------------------
284
 *
265
 *
285
 * unsetenv --
266
 * unsetenv_tcl --
286
 *
267
 *
287
 *	Remove an environment variable, updating the "env" arrays
268
 *	Remove an environment variable, updating the "env" arrays
288
 *	in all interpreters managed by us.
269
 *	in all interpreters managed by us.
Lines 297-308 setenv(name, value) Link Here
297
 */
278
 */
298
279
299
int
280
int
300
unsetenv(name)
281
unsetenv_tcl(name)
301
#ifdef IS_LINUX
302
    const char *name;			/* Name of variable to remove. */
303
#else
304
    char *name;			/* Name of variable to remove. */
282
    char *name;			/* Name of variable to remove. */
305
#endif
306
{
283
{
307
    int index, dummy;
284
    int index, dummy;
308
    char **envPtr;
285
    char **envPtr;
Lines 402-416 EnvTraceProc(clientData, interp, name1, name2, flags) Link Here
402
    }
379
    }
403
380
404
    /*
381
    /*
405
     * If a value is being set, call setenv to do all of the work.
382
     * If a value is being set, call setenv_tcl to do all of the work.
406
     */
383
     */
407
384
408
    if (flags & TCL_TRACE_WRITES) {
385
    if (flags & TCL_TRACE_WRITES) {
409
	setenv(name2, Tcl_GetVar2(interp, "env", name2, TCL_GLOBAL_ONLY), 0);
386
	setenv_tcl(name2, Tcl_GetVar2(interp, "env", name2, TCL_GLOBAL_ONLY));
410
    }
387
    }
411
388
412
    if (flags & TCL_TRACE_UNSETS) {
389
    if (flags & TCL_TRACE_UNSETS) {
413
	unsetenv(name2);
390
	unsetenv_tcl(name2);
414
    }
391
    }
415
    return NULL;
392
    return NULL;
416
}
393
}
(-)a/src/tcl/tclunix.h (-1 / +1 lines)
Lines 101-107 Link Here
101
 */
101
 */
102
102
103
extern int errno;
103
extern int errno;
104
extern int sys_nerr;
104
//extern int sys_nerr;
105
//#ifndef IS_LINUX
105
//#ifndef IS_LINUX
106
//extern char *sys_errlist[];
106
//extern char *sys_errlist[];
107
//#endif
107
//#endif
(-)a/src/tclx/ossupp/makefile (-1 / +1 lines)
Lines 30-36 CFLAGS=$(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ Link Here
30
all: made.tmp
30
all: made.tmp
31
31
32
made.tmp: $(SUPPORT_OBJS)
32
made.tmp: $(SUPPORT_OBJS)
33
	$(AR) cr ../libtcl.a $(SUPPORT_OBJS)
33
	#$(AR) cr ../libtcl.a $(SUPPORT_OBJS)
34
	touch made.tmp
34
	touch made.tmp
35
35
36
#------------------------------------------------------------------------------
36
#------------------------------------------------------------------------------
(-)a/src/tclx/src/tclxgdat.y (-32 / +32 lines)
Lines 64-141 Link Here
64
timedate:               /* empty */
64
timedate:               /* empty */
65
        | timedate item;
65
        | timedate item;
66
66
67
item:   tspec =
67
item:   tspec 
68
                {timeflag++;}
68
                {timeflag++;}
69
        | zone =
69
        | zone 
70
                {zoneflag++;}
70
                {zoneflag++;}
71
        | dtspec =
71
        | dtspec 
72
                {dateflag++;}
72
                {dateflag++;}
73
        | dyspec =
73
        | dyspec 
74
                {dayflag++;}
74
                {dayflag++;}
75
        | rspec =
75
        | rspec 
76
                {relflag++;}
76
                {relflag++;}
77
        | nspec;
77
        | nspec;
78
78
79
nspec:  NUMBER =
79
nspec:  NUMBER 
80
                {if (timeflag && dateflag && !relflag) year = $1;
80
                {if (timeflag && dateflag && !relflag) year = $1;
81
                else {timeflag++;hh = $1/100;mm = $1%100;ss = 0;merid = 24;}};
81
                else {timeflag++;hh = $1/100;mm = $1%100;ss = 0;merid = 24;}};
82
82
83
tspec:  NUMBER MERIDIAN =
83
tspec:  NUMBER MERIDIAN
84
                {hh = $1; mm = 0; ss = 0; merid = $2;}
84
                {hh = $1; mm = 0; ss = 0; merid = $2;}
85
        | NUMBER ':' NUMBER =
85
        | NUMBER ':' NUMBER
86
                {hh = $1; mm = $3; merid = 24;}
86
                {hh = $1; mm = $3; merid = 24;}
87
        | NUMBER ':' NUMBER MERIDIAN =
87
        | NUMBER ':' NUMBER MERIDIAN
88
                {hh = $1; mm = $3; merid = $4;}
88
                {hh = $1; mm = $3; merid = $4;}
89
        | NUMBER ':' NUMBER NUMBER =
89
        | NUMBER ':' NUMBER NUMBER
90
                {hh = $1; mm = $3; merid = 24;
90
                {hh = $1; mm = $3; merid = 24;
91
                dayLight = STANDARD; ourzone = -($4%100 + 60*$4/100);}
91
                dayLight = STANDARD; ourzone = -($4%100 + 60*$4/100);}
92
        | NUMBER ':' NUMBER ':' NUMBER =
92
        | NUMBER ':' NUMBER ':' NUMBER
93
                {hh = $1; mm = $3; ss = $5; merid = 24;}
93
                {hh = $1; mm = $3; ss = $5; merid = 24;}
94
        | NUMBER ':' NUMBER ':' NUMBER MERIDIAN =
94
        | NUMBER ':' NUMBER ':' NUMBER MERIDIAN
95
                {hh = $1; mm = $3; ss = $5; merid = $6;}
95
                {hh = $1; mm = $3; ss = $5; merid = $6;}
96
        | NUMBER ':' NUMBER ':' NUMBER NUMBER =
96
        | NUMBER ':' NUMBER ':' NUMBER NUMBER
97
                {hh = $1; mm = $3; ss = $5; merid = 24;
97
                {hh = $1; mm = $3; ss = $5; merid = 24;
98
                dayLight = STANDARD; ourzone = -($6%100 + 60*$6/100);};
98
                dayLight = STANDARD; ourzone = -($6%100 + 60*$6/100);};
99
99
100
zone:   ZONE =
100
zone:   ZONE
101
                {ourzone = $1; dayLight = STANDARD;}
101
                {ourzone = $1; dayLight = STANDARD;}
102
        | DAYZONE =
102
        | DAYZONE
103
                {ourzone = $1; dayLight = DAYLIGHT;};
103
                {ourzone = $1; dayLight = DAYLIGHT;};
104
104
105
dyspec: DAY =
105
dyspec: DAY
106
                {dayord = 1; dayreq = $1;}
106
                {dayord = 1; dayreq = $1;}
107
        | DAY ',' =
107
        | DAY ','
108
                {dayord = 1; dayreq = $1;}
108
                {dayord = 1; dayreq = $1;}
109
        | NUMBER DAY =
109
        | NUMBER DAY
110
                {dayord = $1; dayreq = $2;};
110
                {dayord = $1; dayreq = $2;};
111
111
112
dtspec: NUMBER '/' NUMBER =
112
dtspec: NUMBER '/' NUMBER
113
                {month = $1; day = $3;}
113
                {month = $1; day = $3;}
114
        | NUMBER '/' NUMBER '/' NUMBER =
114
        | NUMBER '/' NUMBER '/' NUMBER
115
                {month = $1; day = $3; year = $5;}
115
                {month = $1; day = $3; year = $5;}
116
        | MONTH NUMBER =
116
        | MONTH NUMBER
117
                {month = $1; day = $2;}
117
                {month = $1; day = $2;}
118
        | MONTH NUMBER ',' NUMBER =
118
        | MONTH NUMBER ',' NUMBER
119
                {month = $1; day = $2; year = $4;}
119
                {month = $1; day = $2; year = $4;}
120
        | NUMBER MONTH =
120
        | NUMBER MONTH
121
                {month = $2; day = $1;}
121
                {month = $2; day = $1;}
122
        | NUMBER MONTH NUMBER =
122
        | NUMBER MONTH NUMBER
123
                {month = $2; day = $1; year = $3;};
123
                {month = $2; day = $1; year = $3;};
124
124
125
125
126
rspec:  NUMBER UNIT =
126
rspec:  NUMBER UNIT
127
                {relsec +=  60L * $1 * $2;}
127
                {relsec +=  60L * $1 * $2;}
128
        | NUMBER MUNIT =
128
        | NUMBER MUNIT
129
                {relmonth += $1 * $2;}
129
                {relmonth += $1 * $2;}
130
        | NUMBER SUNIT =
130
        | NUMBER SUNIT
131
                {relsec += $1;}
131
                {relsec += $1;}
132
        | UNIT =
132
        | UNIT
133
                {relsec +=  60L * $1;}
133
                {relsec +=  60L * $1;}
134
        | MUNIT =
134
        | MUNIT
135
                {relmonth += $1;}
135
                {relmonth += $1;}
136
        | SUNIT =
136
        | SUNIT
137
                {relsec++;}
137
                {relsec++;}
138
        | rspec AGO =
138
        | rspec AGO
139
                {relsec = -relsec; relmonth = -relmonth;};
139
                {relsec = -relsec; relmonth = -relmonth;};
140
%%
140
%%
141
141
Lines 228-234 time_t daylcorr(future, now) time_t future, now; Link Here
228
228
229
static char *lptr;
229
static char *lptr;
230
230
231
static
231
//static
232
yylex()
232
yylex()
233
{
233
{
234
#ifndef YYSTYPE
234
#ifndef YYSTYPE
(-)a/src/tclx/src/tclxid.c (-1 / +1 lines)
Lines 239-245 Tcl_IdCmd (clientData, interp, argc, argv) Link Here
239
                                  " process group [set]", (char *) NULL);
239
                                  " process group [set]", (char *) NULL);
240
                return TCL_ERROR;
240
                return TCL_ERROR;
241
            }
241
            }
242
            setpgrp ();
242
            setpgid(getpid(), getpid());
243
            return TCL_OK;
243
            return TCL_OK;
244
        }
244
        }
245
        Tcl_AppendResult (interp, tclXWrongArgs, argv [0], 
245
        Tcl_AppendResult (interp, tclXWrongArgs, argv [0], 
(-)a/src/tclx/src/tclxint.h (-1 / +4 lines)
Lines 67-73 Link Here
67
#    include <sys/times.h>
67
#    include <sys/times.h>
68
#endif 
68
#endif 
69
69
70
#include <values.h>
70
//#include "values.h"
71
#include <limits.h>
72
#include <float.h>
73
#define MAXDOUBLE       DBL_MAX
71
#include <grp.h>
74
#include <grp.h>
72
/*
75
/*
73
 * On some systems this is not included by tclUnix.h.
76
 * On some systems this is not included by tclUnix.h.
(-)a/src/tk/tkbind.c (-14 / +62 lines)
Lines 229-239 static ModInfo modArray[] = { Link Here
229
    "Button5",		Button5Mask,	0,
229
    "Button5",		Button5Mask,	0,
230
    "Mod1",		Mod1Mask,	0,
230
    "Mod1",		Mod1Mask,	0,
231
    "M1",		Mod1Mask,	0,
231
    "M1",		Mod1Mask,	0,
232
    "Meta",		Mod1Mask,	0,
232
    "Meta",		META_MASK,	0,
233
    "M",		Mod1Mask,	0,
233
    "M",		META_MASK,	0,
234
    "Mod2",		Mod2Mask,	0,
234
    "Mod2",		Mod2Mask,	0,
235
    "M2",		Mod2Mask,	0,
235
    "M2",		Mod2Mask,	0,
236
    "Alt",		Mod2Mask,	0,
236
    "Alt",		ALT_MASK,	0,
237
    "Mod3",		Mod3Mask,	0,
237
    "Mod3",		Mod3Mask,	0,
238
    "M3",		Mod3Mask,	0,
238
    "M3",		Mod3Mask,	0,
239
    "Mod4",		Mod4Mask,	0,
239
    "Mod4",		Mod4Mask,	0,
Lines 383-390 static PatSeq * FindSequence _ANSI_ARGS_((Tcl_Interp *interp, Link Here
383
static char *		GetField _ANSI_ARGS_((char *p, char *copy, int size));
383
static char *		GetField _ANSI_ARGS_((char *p, char *copy, int size));
384
static KeySym		GetKeySym _ANSI_ARGS_((TkDisplay *dispPtr,
384
static KeySym		GetKeySym _ANSI_ARGS_((TkDisplay *dispPtr,
385
			    XEvent *eventPtr));
385
			    XEvent *eventPtr));
386
static PatSeq *		MatchPatterns _ANSI_ARGS_((BindingTable *bindPtr,
386
static PatSeq *		MatchPatterns _ANSI_ARGS_((TkDisplay *dispPtr,
387
			    PatSeq *psPtr));
387
			    BindingTable *bindPtr, PatSeq *psPtr));
388
388
389
/*
389
/*
390
 *--------------------------------------------------------------
390
 *--------------------------------------------------------------
Lines 1034-1047 Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr) Link Here
1034
	key.detail = detail;
1034
	key.detail = detail;
1035
	hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
1035
	hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
1036
	if (hPtr != NULL) {
1036
	if (hPtr != NULL) {
1037
	    matchPtr = MatchPatterns(bindPtr,
1037
	    matchPtr = MatchPatterns(dispPtr, bindPtr,
1038
		    (PatSeq *) Tcl_GetHashValue(hPtr));
1038
		    (PatSeq *) Tcl_GetHashValue(hPtr));
1039
	}
1039
	}
1040
	if ((detail != 0) && (matchPtr == NULL)) {
1040
	if ((detail != 0) && (matchPtr == NULL)) {
1041
	    key.detail = 0;
1041
	    key.detail = 0;
1042
	    hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
1042
	    hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
1043
	    if (hPtr != NULL) {
1043
	    if (hPtr != NULL) {
1044
		matchPtr = MatchPatterns(bindPtr,
1044
		matchPtr = MatchPatterns(dispPtr, bindPtr,
1045
			(PatSeq *) Tcl_GetHashValue(hPtr));
1045
			(PatSeq *) Tcl_GetHashValue(hPtr));
1046
	    }
1046
	    }
1047
	}
1047
	}
Lines 1576-1582 GetKeySym(dispPtr, eventPtr) Link Here
1576
 */
1576
 */
1577
1577
1578
static PatSeq *
1578
static PatSeq *
1579
MatchPatterns(bindPtr, psPtr)
1579
MatchPatterns(dispPtr, bindPtr, psPtr)
1580
    TkDisplay *dispPtr;
1580
    BindingTable *bindPtr;	/* Information about binding table, such
1581
    BindingTable *bindPtr;	/* Information about binding table, such
1581
				 * as ring of recent events. */
1582
				 * as ring of recent events. */
1582
    register PatSeq *psPtr;	/* List of pattern sequences. */
1583
    register PatSeq *psPtr;	/* List of pattern sequences. */
Lines 1609-1617 MatchPatterns(bindPtr, psPtr) Link Here
1609
	    if (ringCount <= 0) {
1610
	    if (ringCount <= 0) {
1610
		goto nextSequence;
1611
		goto nextSequence;
1611
	    }
1612
	    }
1612
	    if (eventPtr->xany.window != window) {
1613
		goto nextSequence;
1614
	    }
1615
	    if (eventPtr->xany.type != patPtr->eventType) {
1613
	    if (eventPtr->xany.type != patPtr->eventType) {
1616
		/*
1614
		/*
1617
		 * If the event is a mouse motion, button release,
1615
		 * If the event is a mouse motion, button release,
Lines 1624-1634 MatchPatterns(bindPtr, psPtr) Link Here
1624
			|| (eventPtr->xany.type == ButtonRelease)
1622
			|| (eventPtr->xany.type == ButtonRelease)
1625
			|| (eventPtr->xany.type == KeyRelease)
1623
			|| (eventPtr->xany.type == KeyRelease)
1626
			|| (eventPtr->xany.type == NoExpose)
1624
			|| (eventPtr->xany.type == NoExpose)
1625
			|| (eventPtr->xany.type == EnterNotify)
1626
			|| (eventPtr->xany.type == LeaveNotify)
1627
			|| (eventPtr->xany.type == GraphicsExpose)) {
1627
			|| (eventPtr->xany.type == GraphicsExpose)) {
1628
		    goto nextEvent;
1628
		    goto nextEvent;
1629
		}
1629
		}
1630
		goto nextSequence;
1630
		goto nextSequence;
1631
	    }
1631
	    }
1632
	    if (eventPtr->xany.window != window) {
1633
		goto nextSequence;
1634
	    }
1632
1635
1633
	    flags = flagArray[eventPtr->type];
1636
	    flags = flagArray[eventPtr->type];
1634
	    if (flags & KEY_BUTTON_MOTION) {
1637
	    if (flags & KEY_BUTTON_MOTION) {
Lines 1638-1650 MatchPatterns(bindPtr, psPtr) Link Here
1638
	    } else {
1641
	    } else {
1639
		state = 0;
1642
		state = 0;
1640
	    }
1643
	    }
1641
	    if ((state & patPtr->needMods)
1644
	    if (patPtr->needMods != 0) {
1642
		    != patPtr->needMods) {
1645
	        int modMask = patPtr->needMods;
1643
		goto nextSequence;
1646
1647
		if (!dispPtr->metaModMask && !dispPtr->altModMask && !dispPtr->modeModMask) {
1648
			int i, max;
1649
			XModifierKeymap *modMapPtr;
1650
			KeyCode *codePtr;
1651
			KeySym keysym;
1652
1653
			modMapPtr = XGetModifierMapping(dispPtr->display);
1654
			codePtr = modMapPtr->modifiermap;
1655
			max = 8*modMapPtr->max_keypermod;
1656
1657
			for (i = 0; i < max; i++, codePtr++) {
1658
				if (*codePtr == 0) {
1659
					continue;
1660
				}
1661
				keysym = XKeycodeToKeysym(dispPtr->display, *codePtr, 0);
1662
				if (keysym == XK_Mode_switch) {
1663
					dispPtr->modeModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
1664
				}
1665
				if ((keysym == XK_Meta_L) || (keysym == XK_Meta_R)) {
1666
					dispPtr->metaModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
1667
				}
1668
				if ((keysym == XK_Alt_L) || (keysym == XK_Alt_R)) {
1669
					dispPtr->altModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
1670
				}
1671
			}
1672
		}
1673
	        if ((modMask & META_MASK) && (dispPtr->metaModMask != 0)) {
1674
	                modMask = (modMask & ~META_MASK) | dispPtr->metaModMask;
1675
	        }
1676
	        if ((modMask & ALT_MASK) && (dispPtr->altModMask != 0)) {
1677
	                modMask = (modMask & ~ALT_MASK) | dispPtr->altModMask;
1678
	        }
1679
1680
	        if ((state & META_MASK) && (dispPtr->metaModMask != 0)) {
1681
	                state = (state & ~META_MASK) | dispPtr->metaModMask;
1682
	        }
1683
	        if ((state & ALT_MASK) && (dispPtr->altModMask != 0)) {
1684
	                state = (state & ~ALT_MASK) | dispPtr->altModMask;
1685
	        }
1686
1687
	        if ((state & modMask) != modMask) {
1688
	                goto nextSequence;
1689
	        }
1644
	    }
1690
	    }
1691
#if 0
1645
	    if ((state & patPtr->hateMods) != 0) {
1692
	    if ((state & patPtr->hateMods) != 0) {
1646
		goto nextSequence;
1693
		goto nextSequence;
1647
	    }
1694
	    }
1695
#endif
1648
	    if ((patPtr->detail != 0)
1696
	    if ((patPtr->detail != 0)
1649
		    && (patPtr->detail != *detailPtr)) {
1697
		    && (patPtr->detail != *detailPtr)) {
1650
		goto nextSequence;
1698
		goto nextSequence;
(-)a/src/tk/tkcanvas.c (-1 / +1 lines)
Lines 1488-1494 ConfigureCanvas(interp, canvasPtr, argc, argv, flags) Link Here
1488
1488
1489
#if defined(USE_XPM3)
1489
#if defined(USE_XPM3)
1490
//#include "xpmtk.h"
1490
//#include "xpmtk.h"
1491
#include <xpm.h>
1491
#include <X11/xpm.h>
1492
/*
1492
/*
1493
 *--------------------------------------------------------------
1493
 *--------------------------------------------------------------
1494
 *
1494
 *
(-)a/src/tk/tkcolor.c (-27 / +52 lines)
Lines 484-525 Tk_VisInfo(Screen *screen) Link Here
484
#else
484
#else
485
	scrnum = Tk_IndexOfScreen(screen);
485
	scrnum = Tk_IndexOfScreen(screen);
486
	vTemplate.screen = scrnum;
486
	vTemplate.screen = scrnum;
487
	vTemplate.depth = 8;
487
	vTemplate.class = TrueColor;
488
	vTemplate.class = PseudoColor;
489
	visualList =
488
	visualList =
490
	  XGetVisualInfo(DisplayOfScreen(screen),
489
	  XGetVisualInfo(DisplayOfScreen(screen),
491
			 VisualScreenMask |
490
			 VisualScreenMask |
492
			 VisualDepthMask |
493
			 VisualClassMask,
491
			 VisualClassMask,
494
			 &vTemplate, &visualsMatched);
492
			 &vTemplate, &visualsMatched);
495
	if (visualsMatched > 0) {
493
	info->visual = NULL;
496
	    info->visual = visualList[0].visual;
494
497
	    info->depth = 8;
495
	if (visualList != NULL) {
498
	    info->pixmap = XCreatePixmap(screen->display,
496
	  int i;
499
					 RootWindowOfScreen(screen),
497
	  for (i = 0; i < visualsMatched; i++) {
500
					 1, 1, 8);
498
	      if (visualList[i].depth > 24)
501
//fprintf(stderr, "TK_CreateColormap %d\n", TK_CreateColormap);
499
		continue; /* Most likely broken */
502
	    if ((TK_CreateColormap == 0) &&
500
503
		(info->visual == DefaultVisualOfScreen(screen))) {
501
	      info->visual = visualList[i].visual;
504
	      info->colormap = DefaultColormapOfScreen(screen);
502
	      info->depth = visualList[i].depth;
505
	      info->gc = DefaultGCOfScreen(screen);
503
506
	    } else {
504
	      break;
507
	      info->colormap =
505
	  }
508
		XCreateColormap(screen->display,
506
	}
509
				RootWindowOfScreen(screen),
507
510
				info->visual, AllocNone);
508
	if (info->visual == NULL) {
511
	      info->gc =
512
		XCreateGC(screen->display,
513
			  info->pixmap, 0, &values);
514
	    }
515
	} else {
516
	    info->visual = XDefaultVisualOfScreen(screen);
509
	    info->visual = XDefaultVisualOfScreen(screen);
517
	    info->depth = XDefaultDepthOfScreen(screen);
510
	    info->depth = XDefaultDepthOfScreen(screen);
518
	    info->pixmap = XCreatePixmap(screen->display,
519
					 RootWindowOfScreen(screen),
520
					 1, 1, info->depth);
521
	    info->colormap = XDefaultColormapOfScreen(screen);
511
	    info->colormap = XDefaultColormapOfScreen(screen);
522
	    info->gc = DefaultGCOfScreen(screen);
512
	    info->gc = DefaultGCOfScreen(screen);
513
514
	    if (info->depth == 8) {
515
	      vTemplate.screen = scrnum;
516
	      vTemplate.class = PseudoColor;
517
	      vTemplate.depth = 8;
518
	      visualList = XGetVisualInfo(DisplayOfScreen(screen),
519
	      		VisualScreenMask |
520
			VisualDepthMask |
521
			VisualClassMask,
522
			&vTemplate, &visualsMatched);
523
524
	      if (visualsMatched > 0) {
525
	          info->visual = visualList[0].visual;
526
	          info->depth = visualList[0].depth;
527
528
	      }
529
	    }
530
	}
531
532
	info->pixmap = XCreatePixmap(screen->display,
533
				 RootWindowOfScreen(screen),
534
				 1, 1, info->depth);
535
	
536
	if ((TK_CreateColormap == 0) &&
537
	    (info->visual == DefaultVisualOfScreen(screen))) {
538
	  info->colormap = DefaultColormapOfScreen(screen);
539
	  info->gc = DefaultGCOfScreen(screen);
540
	} else {
541
	  info->colormap =
542
	     XCreateColormap(screen->display,
543
	     	RootWindowOfScreen(screen),
544
	     	info->visual, AllocNone);
545
	  info->gc =
546
	     XCreateGC(screen->display,
547
	       info->pixmap, 0, &values);
523
	}
548
	}
524
549
525
	XFree((char *)visualList);
550
	XFree((char *)visualList);
(-)a/src/tk/tkgrab.c (-2 lines)
Lines 498-505 TkPointerEvent(eventPtr, winPtr) Link Here
498
    int appGrabbed = 0;			/* Non-zero means event is being
498
    int appGrabbed = 0;			/* Non-zero means event is being
499
					 * reported to an application that is
499
					 * reported to an application that is
500
					 * affected by the grab. */
500
					 * affected by the grab. */
501
#define ALL_BUTTONS \
502
	(Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
503
    static unsigned int state[] = {
501
    static unsigned int state[] = {
504
	Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
502
	Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
505
    };
503
    };
(-)a/src/tk/tkint.h (+9 lines)
Lines 38-43 Link Here
38
#include "tclhash.h"
38
#include "tclhash.h"
39
#endif
39
#endif
40
40
41
#define META_MASK	(AnyModifier<<1)
42
#define ALT_MASK	(AnyModifier<<2)
43
44
#define ALL_BUTTONS \
45
	(Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
46
41
/*
47
/*
42
 * One of the following structures is maintained for each display
48
 * One of the following structures is maintained for each display
43
 * containing a window managed by Tk:
49
 * containing a window managed by Tk:
Lines 76-81 typedef struct TkDisplay { Link Here
76
				 * retrieved from the server yet. */
82
				 * retrieved from the server yet. */
77
    KeySym *keySyms;		/* Array of KeySyms, returned by
83
    KeySym *keySyms;		/* Array of KeySyms, returned by
78
				 * XGetKeyboardMapping. */
84
				 * XGetKeyboardMapping. */
85
    unsigned int modeModMask;
86
    unsigned int metaModMask;
87
    unsigned int altModMask;
79
88
80
    /*
89
    /*
81
     * Information used by tkError.c only:
90
     * Information used by tkError.c only:
(-)a/src/tk/tkpixmap.c (-1 / +1 lines)
Lines 41-47 static char *AtFSid = "$Header: tkPixmap.c[1.1] Mon Sep 28 14:12:35 1992 garfiel Link Here
41
 * Include the xpm 3 defines for color pixmaps
41
 * Include the xpm 3 defines for color pixmaps
42
 */
42
 */
43
//#include "xpmtk.h"
43
//#include "xpmtk.h"
44
#include <xpm.h>
44
#include <X11/xpm.h>
45
45
46
/*
46
/*
47
 * One of the following data structures exists for each bitmap that is
47
 * One of the following data structures exists for each bitmap that is
(-)a/src/tk/tkscale.c (-1 / +1 lines)
Lines 1317-1323 ScaleMouseProc(clientData, eventPtr) Link Here
1317
		eventPtr->xmotion.x, eventPtr->xmotion.y));
1317
		eventPtr->xmotion.x, eventPtr->xmotion.y));
1318
    } else if ((eventPtr->type == ButtonPress)
1318
    } else if ((eventPtr->type == ButtonPress)
1319
/*	    && (eventPtr->xbutton.button == Button1) */
1319
/*	    && (eventPtr->xbutton.button == Button1) */
1320
	    && (eventPtr->xbutton.state == 0)) {
1320
	    && ((eventPtr->xbutton.state & ALL_BUTTONS) == 0)) {
1321
	scalePtr->flags |= BUTTON_PRESSED;
1321
	scalePtr->flags |= BUTTON_PRESSED;
1322
	SetScaleValue(scalePtr, PixelToValue(scalePtr,
1322
	SetScaleValue(scalePtr, PixelToValue(scalePtr,
1323
		eventPtr->xbutton.x, eventPtr->xbutton.y));
1323
		eventPtr->xbutton.x, eventPtr->xbutton.y));
(-)a/src/tk/tkscrbar.c (-1 / +1 lines)
Lines 974-980 ScrollbarMouseProc(clientData, eventPtr) Link Here
974
		    eventPtr->xmotion.y));
974
		    eventPtr->xmotion.y));
975
	}
975
	}
976
    } else if ((eventPtr->type == ButtonPress)
976
    } else if ((eventPtr->type == ButtonPress)
977
	    && (eventPtr->xbutton.state == 0)) {
977
	    && ((eventPtr->xbutton.state & ALL_BUTTONS) == 0)) {
978
	scrollPtr->pressField = scrollPtr->mouseField;
978
	scrollPtr->pressField = scrollPtr->mouseField;
979
	if (scrollPtr->pressField != SLIDER) {
979
	if (scrollPtr->pressField != SLIDER) {
980
	    scrollPtr->autoRepeat = Tk_CreateTimerHandler(
980
	    scrollPtr->autoRepeat = Tk_CreateTimerHandler(
(-)a/src/tk/tkwindow.c (+3 lines)
Lines 360-365 GetScreen(interp, screenName, screenPtr) Link Here
360
	    dispPtr->selectionSerial = 0;
360
	    dispPtr->selectionSerial = 0;
361
	    dispPtr->multipleAtom = None;
361
	    dispPtr->multipleAtom = None;
362
	    dispPtr->atomInit = 0;
362
	    dispPtr->atomInit = 0;
363
	    dispPtr->modeModMask = 0;
364
	    dispPtr->metaModMask = 0;
365
	    dispPtr->altModMask = 0;
363
	    dispPtr->cursorFont = None;
366
	    dispPtr->cursorFont = None;
364
	    dispPtr->grabWinPtr = NULL;
367
	    dispPtr->grabWinPtr = NULL;
365
	    dispPtr->ungrabWinPtr = NULL;
368
	    dispPtr->ungrabWinPtr = NULL;
(-)a/src/tk/tkwm.c (-23 / +22 lines)
Lines 349-384 TkWmMapWindow(winPtr) Link Here
349
    if (wmPtr->hints.initial_state == NormalState) {
349
    if (wmPtr->hints.initial_state == NormalState) {
350
	winPtr->flags |= TK_MAPPED;
350
	winPtr->flags |= TK_MAPPED;
351
    }
351
    }
352
    if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
352
    if (wmPtr->flags & WM_NEVER_MAPPED) {
353
	return 1;
353
        wmPtr->flags &= ~WM_NEVER_MAPPED;
354
    }
355
    wmPtr->flags &= ~WM_NEVER_MAPPED;
356
354
357
    /*
355
        /*
358
     * This is the first time this window has ever been mapped.
356
         * This is the first time this window has ever been mapped.
359
     * Store all the window-manager-related information for the
357
         * Store all the window-manager-related information for the
360
     * window.
358
         * window.
361
     */
359
         */
362
360
363
#ifndef X11R3
361
#ifndef X11R3
364
    if (wmPtr->titleUid == NULL) {
362
        if (wmPtr->titleUid == NULL) {
365
	wmPtr->titleUid = winPtr->nameUid;
363
            wmPtr->titleUid = winPtr->nameUid;
366
    }
364
        }
367
    if (XStringListToTextProperty(&wmPtr->titleUid, 1, &textProp)  != 0) {
365
        if (XStringListToTextProperty(&wmPtr->titleUid, 1, &textProp)  != 0) {
368
	XSetWMName(winPtr->display, winPtr->window, &textProp);
366
            XSetWMName(winPtr->display, winPtr->window, &textProp);
369
	XFree((char *) textProp.value);
367
            XFree((char *) textProp.value);
370
    }
368
        }
371
#endif
369
#endif
372
370
373
    TkWmSetClass(winPtr);
371
        TkWmSetClass(winPtr);
374
    TkWmSetWmProtocols(winPtr);
372
        TkWmSetWmProtocols(winPtr);
375
373
376
    if (wmPtr->iconName != NULL) {
374
        if (wmPtr->iconName != NULL) {
377
	XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
375
            XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
378
    }
376
        }
379
377
380
    if (wmPtr->master != None) {
378
        if (wmPtr->master != None) {
381
	XSetTransientForHint(winPtr->display, winPtr->window, wmPtr->master);
379
            XSetTransientForHint(winPtr->display, winPtr->window, wmPtr->master);
380
        }
382
    }
381
    }
383
382
384
    wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
383
    wmPtr->flags |= WM_UPDATE_SIZE_HINTS;

Return to bug 205707